nginxnginx-configjwilder-nginx-proxy

Deny access include file not working in nginx conf


Include not taken into account to deny access to certain ip

Nginx 1.12 is configured as a proxy.

I have 2 config files :

nginx.conf
mydomain.conf

I followed a tuto to have a list of deny ip list, all in a 3rd conf file called blockips.conf. Everyline in that conf file is like :

deny xxx.xxx.xxx.xxx;

now, i tried to include like that in either the http or server section of both nginx.conf and mydomain.conf files (not both at the same time, but tring 1st and then 2n) but either it doesn't block either it crash.

include blockips.conf;

but when i put only the

deny xxx.xxx.xxx.xxx; 

directly in the mydomain.conf in the server section then the ip is blocked. of course i could put all my list of ips within mydomain.conf file but it makes mote sense to have it external right ? but then it doesn't work. Of course, i've tried to have my blockips.conf file with only one line (just to make sure it is not a ; missing).

and i have checked the files right and they are all identical 644 under root

Thank you


Solution

  • There was 2 nginx.conf files on my system and i was not modifying the correct one! Just do a nginx -t just to verify where is the correct file.

    now it is working.