It is not uncommon for network access rules to restrict traffic from undifferentiated traffic from major cloud providers. Such a practice for public-facing applications is a reasonable security measure. However, this can pose some challenges when performing load testing, especially with scale as these resources typically originate from within a large data center. In this brief article, we will show you how to set up X-Forwarded-For
headers in JMeter to help navigate this issue and allow your requests to reach your target test application.
When to Use X-Forwarded-For Headers
If you are using a cloud-based load testing platform like RedLine13, there is a good chance that load generator instances reside within a cloud-based infrastructure such as AWS. Owing to that, it is not uncommon for organization security policies to restrict traffic originating from undifferentiated cloud providers. One method to allow your traffic to pass through access control lists (ACLs) and reach your target test servers is to use the X-Forwarded-For
header.
When an X-Forwarded-For
header is set, it informs the network where a request originated from. It is often used by proxy servers to identify underlying sources of forwarded requests. Similarly, it can be used to identify approved sources of traffic for requests originating from cloud provider networks.
Setting X-Forwarded-For Headers
JMeter has a component called the HTTP Header Manager, which allows you to add or replace headers for associated HTTP requests. For the specific example of X-Forwarded-For
headers, we can define the header name, and set the value to a desired IP address as shown below:
![Setting the X-Forwarded-For header in JMeter using the HTTP Header Manager](https://d13vhgz95ul9hy.cloudfront.net/blog/wp-content/uploads/2024/05/word-image-11123-2.png)
In this case, associated HTTP requests will be treated as if they originated from the IP address 13.224.214.30
, versus an organic request from the actual IP of the instance. The caveat is of course that the implementation of ACL rules must honor presented X-Forwarded-For
addresses.
Did you know that RedLine13 offers a full-featured, time-limited free trial? Sign up now, and start testing today!