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

[Help] Custom error_page is not working. Why?

$
0
0
I'm using latest nginx(sid) on Debian, and my nginx server's config is like this:

server {
server_....
error_page 400 401 403 404 405 408 500 502 503 504 /_an_error_page_.html;

... (misc 403 rules, such as: "if ($blah != 1){return 403;}") ...

location /_an_error_page_.html {internal;allow all;}
location /robots.txt {allow all;}
}

When I connect to https://my.website/ with bad browser/IP/whatever, nginx return 403 as expected
but it return "403 Forbidden - nginx"(generic error).

> "GET / HTTP/1.1" 403 320 "-" "curl/X"

And when I changed "error_page" line to(added =200):

> error_page 400 401 403 404 405 408 500 502 503 504 =200 /_an_error_page_.html;

It just return empty string(0 byte).

> "GET / HTTP/1.1" 200 0 "-" "curl/X"

Of course I reloaded nginx after modified my config file.
Why this is not working, and what I should do to make this work?

Viewing all articles
Browse latest Browse all 4759

Trending Articles



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