Controlling IP Addresses of Requests
By default, the proxy servers will choose a random IP for every request. But you can modify that behavior using custom headers.
The following custom headers let you specify exact IPs. In order to use them, you must get IP values from the
X-ProxyMesh-IP response header. You can find more details on the X-ProxyMesh custom headers at Proxy Server Request & Response Headers. Keep in mind that for HTTPS requests, custom headers must be handled differently. For details, please see:
- HTTPS CONNECT Method in ProxyMesh Request & Response Headers.
- Article Proxy Server Headers over HTTPS.
Use this header when you want to specify a particular IP for a request. This IP should come from the
X-ProxyMesh-IP response header of a previous request. If the IP is no longer available, you will get a
502 error code with the
X-ProxyMesh-IP-Not-Found response header.
Use this header when you want to use a specific IP for a request, but you also want the request to succeed even if the IP is no longer available. This is like the
X-ProxyMesh-IP header, but when an IP is not available, a random IP is chosen instead. You can tell when this happens by comparing the
X-ProxyMesh-IP response header to the IP you sent with the
X-ProxyMesh-Prefer-IP header. If they are different, then the IP you tried to use is no longer available.
Use this header to exclude a specific IP from the available choices. An IP other than the excluded IP will be chosen at random.
You can also send a comma-separated-values list of IPs to exclude multiple IPs. You will get a
502 error code if no more IPs are available, after excluding the IPs sent in the header.
Do not cache the IPs for more than 1 day, as they will be out-of-date or offline within 12 hours.
Authentication Header String
Another method for controlling the IP addresses is to use a random string in the
Proxy-Authorization header. You'll find the details in "Authentication Header String" in Proxy Server Requests over HTTPS.
Recording IP Addresses of Requests
For future use, you may want to make a list of the IP addresses that the proxy sends to a remote server for your request. You could send IPs, for example, in one of the custom headers discussed in this article. Or, in high-traffic operations, you could choose multiple IPs from a list to reduce concurrent requests from a single IP.
With HTTP requests, the place to find the IP address is in the response header. But with an HTTPS request, you need to look in the response to the initial CONNECT request.
IP Addresses Blocked by Geolocation
Some remote sites use geolocation to detect the location of IP addresses from a specific server. Geolocation may report some IP addresses as being in a different location from the one you intend. That can be a problem if the reported geolocation of the IP address is far distant from the remote site.
If this causes your requests to be blocked, please read the IP Geolocation article for possible solutions.