Welcome! Log In Create A New Profile

Advanced

GeoIP Module for Blocking IP in http_x_forwarded_for

January 11, 2018 07:17AM
GeoIP module is able to block request on basis of remote address which is IP of the remote device or user but not on basis of X-Forwarded-For IP if it has multiple IP address in it.

There is Frontend Server( Server A) which receives the request and send it to Intermediate Server (Server B)
We have GeoIP module installed on Intermediate Server i.e. Server B


Server B <--- Server A <---- User

When Server B , receives the request from Server A, remote address (remote_addr) for Server B is IP of Server A.
Device/User IP is in http_x_forwarded_for field .
If http_x_forwarded_for has single IP in it GeoIP module is able to block the IP on the basis of blocking applied.

If http_x_forwarded_for has multiple IP i.e IP of User as well as IP of some Proxy Server or IP of Server A, then its not able to block the request.

Below is the configuration :

geoip_country /usr/share/GeoIP/GeoIP.dat;
geoip_proxy IP_OF_ServerA; // GeoIP module ignores remote_addr considering it as trusted and refers to X-Forwarded For

map $geoip_country_code $allowed_country {
default no;
US yes;
}

http_x_forwarded_for = { User IP of UK } - Request from this IP is getting blocked

http_x_forwarded_for = { User IP of UK , Proxy IP of US } - This request is not getting blocked

http_x_forwarded_for = { User IP of UK , IP of Server A } - This request is not getting blocked

It seems nginx GeoIP Module refers to Last IP in http_x_forwarded_for field for applying the blocking method.

Is there a way to check for First IP Address in http_x_forwarded_for for blocking the request ?

Please suggest

Please refer this for Solution in Apache
https://dev.maxmind.com/geoip/legacy/mod_geoip2/
Subject Author Posted

GeoIP Module for Blocking IP in http_x_forwarded_for

anish10dec January 11, 2018 07:17AM

Re: GeoIP Module for Blocking IP in http_x_forwarded_for

Maxim Dounin January 11, 2018 09:16AM

Re: GeoIP Module for Blocking IP in http_x_forwarded_for

anish10dec January 17, 2018 07:33AM

Re: GeoIP Module for Blocking IP in http_x_forwarded_for

Maxim Dounin January 17, 2018 09:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 106
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready