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

How to use a custom 403 page

$
0
0
Wondering if I could get some help. I am unable to serve a custom 403 page.
I am using the geoip module to block a few ip addresses. I need to serve a custom xml file as the 403. My problem is that even tho I have set everything up according to the directions (i think) I still get the default nginx 403 page. Please take a look at my /etc/nginx/sites-enabled/default and let me know what is out of place.

.....
###redirect IP_1
geo $bad_user {
default 0;
bad.ip.1/32 1;
bad.ip.2/32 1;
}

server {

.........

####custom 403 error page for ip block
error_page 403 /error.xml;
location = /error.xml {
root /var/www/static;
allow all;
}

####redirect IP_2
if ($bad_user) {
return 403;
}

I have verified that directories and xml file have the correct permission. I am able to access the error.xml file if I disable the geoip block. Please let me know if you have any thoughts, ideas or what other info I can provide.

Thanks for your help

Viewing all articles
Browse latest Browse all 4759

Trending Articles



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