Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

custom 403 by deny rule

$
0
0
Hello, i want to show a custom 403 for "deny" requests, since i have two places where a 403 can be shown, one is any IP from a list and the other one is when there is a PHP request in a forbidden directory

IE: show no-php403.html if the request is catched by the first (or any?) case and no-spammers-CN.html if they are catched by its IP

is this possible?



my-site.conf
------------------------------------------------------------------------------------------------------------------------------------------------------------
location ~* ^/(?:cache|uploads)/.*\.(?:pl|php[345]*)$ {
access_log off;
log_not_found off;
return 403; # or 404/403
}



-------------------
custom-deny.conf (included inside all vhosts)
------------------------------------------------------------------------------------------------------------------------------------------------------------
deny 182.136.0.0/16;
error_page 403 /error403.html;

location = /error403.html {
access_log /var/log/nginx/error_403.log;
root /usr/share/nginx/html;
allow all;
ssi on;
}


Thanks!

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>