0

I'm using Nginx and GeoIP to block certain countries (to the whole site).
Is it possible to block just one specific directory?

This way:

www.domain.com/
Everyone can access
www.domain.com/ES
Only spanish IP's can access, no one else.
www.domain.com/OTHER
Everyone can access OTHER except China.

(Countries used merely as an example)
Thank you.

And yes, I am aware that GeoIP isn't always accurate, but helps a lot.

1 Answers1

1

Use the ngx_http_access_module and ngx_http_geo_module.

location /ES {
    # Enter the Allowed IP blocks
    allow x.x.x.x;
    deny all;
}
location /OTHER {
    # Enter the Denied IP blocks
    deny x.x.x.x.;
    allow all;
}

Source:

http://nginx.org/en/docs/http/ngx_http_access_module.html http://nginx.org/en/docs/http/ngx_http_geo_module.html

Tan Hong Tat
  • 910
  • 5
  • 6