Reputation: 441
I'm trying to display a custom 404 error page on my site, but it seems that Nginx does not catch the 404. Instead, it shows a 404 page from Gunicorn(flask app)
nginx.conf:
server {
listen 80 default_server;
server_name example.com www.example.com;
location / {
proxy_pass http://flask:8080/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
error_page 404 /notfound.html;
location /notfound.html {
root /var/www/html;
}
error_page 500 502 503 504 /maintenance.html;
location /maintenance.html {
root /var/www/html;
}
}
Both flask app and Nginx are running on separate docker containers.
I purposefully brought the flask app down to see what happens, after a while It redirects to 504(Timeout) and the maintenance.html appeared. - works fine.
But on a 404 error instead of displaying this custom notfound.html
, it displays a 404 Not Found
from Flask App (The 404 page did not had any nginx version on it).
Upvotes: 1
Views: 644