geoip_proxy_recursive
This directive enables recursive geographical IP lookups for proxy servers in NGINX.
Description
The geoip_proxy_recursive directive is utilized within the http context of NGINX to control the behavior of GeoIP-enabled proxy requests. When set to 'on', this directive allows the module to perform recursive lookups for the client's geographical information. This is particularly useful for scenarios where a client connects through multiple proxies, preserving the original client's IP address when determining geographical location. The directive ensures that the GeoIP module fetches data from the real IP of the client, as opposed to the last proxy's IP.
When this directive is enabled, NGINX will check headers such as X-Forwarded-For or X-Real-IP to retrieve the true client IP address. If these headers contain multiple addresses, NGINX will traverse them to find the originating IP address, enabling accurate location data for GeoIP lookups. This functionality is crucial for applications that require geo-targeted content or security measures based on geographical locations.
The directive is interpreted as a flag, meaning it has a binary state. Either it is activated (set to 'on') or not (set to 'off'). The behavior remains consistent with NGINX's overall design of toggling directives between enabled or disabled states, providing flexibility based on the specific requirements of environmental configurations.
Config Example
http {
geoip_proxy_recursive on;
geoip_country /path/to/GeoIP.dat;
}Ensure that the GeoIP module is installed and properly configured.
Using this directive without understanding how proxies affect IP address headers may lead to inaccurate geographical data.
Incorrect ordering of proxies without proper header settings can result in value loss for the IP lookup.