Block countries - Nginx

Francis Daly francis at daoine.org
Thu May 24 22:54:47 UTC 2018


On Thu, May 24, 2018 at 09:57:24PM +0800, Sathish Kumar wrote:

Hi there,

> The client is already sending the X-Forwarded-For but when it received on
> server it has multiple ips, how we can filter only the 1st IP and pass it
> to geo ip module to block the IP based on Country.

Does http://nginx.org/en/docs/http/ngx_http_realip_module.html do what
you want?

Note: you will have to decide which part of X-Forwarded-For to trust,
since the client can write anything they want to in there. That is what
set_real_ip_from is for.

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list