Welcome! Log In Create A New Profile

Advanced

Re: Block countries - Nginx

Aleksandar Lazic
May 22, 2018 04:28AM
On 21/05/2018 11:49, Sathish Kumar wrote:
> Hi All,
>
> I have a requirement to block certain countries coming to our website. I
> managed to achieved it using the ngx_http_geoip_module. I have a problem
> now, if the request comes through Amazon API Gateway, how can I read the
> X-forwarded-for header or block these request too.
>
> nginx.conf
> map $geoip_country_code $allow_country {
> default yes;
> SG no;
> }
>
>
> geoip_country /etc/nginx/GeoIP.dat; # the country IP database
> geoip_city /etc/nginx/GeoLiteCity.dat; # the city IP database
>
>
> domain.conf
> if ($allow_country = no) {
> return 444;
> }

You can try to use $http_x_forwarded_for in the map.
I think this blog post could point you in the right direction.

https://serversforhackers.com/c/nginx-mapping-headers

> Thanks & Regards
> Sathish.V

Best Regards
aleks
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Block countries - Nginx

Sathish Kumar May 20, 2018 11:52PM

Re: Block countries - Nginx

basti May 21, 2018 02:04AM

Re: Block countries - Nginx

Sathish Kumar May 21, 2018 09:38PM

Re: Block countries - Nginx

basti May 22, 2018 03:10AM

Re: Block countries - Nginx

Frank Liu May 22, 2018 04:46AM

Re: Block countries - Nginx

Sathish Kumar May 23, 2018 09:52PM

Re: Block countries - Nginx

Frank Liu May 23, 2018 11:28PM

Re: Block countries - Nginx

pbooth May 23, 2018 11:48PM

Re: Block countries - Nginx

Sathish Kumar May 24, 2018 09:58AM

Re: Block countries - Nginx

Francis Daly May 24, 2018 06:56PM

Re: Block countries - Nginx

pbooth May 25, 2018 01:06AM

Re: Block countries - Nginx

Aleksandar Lazic May 22, 2018 04:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 256
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready