I'm trying to serve a maintenance page. So I gave try_files a try and always serve maintenance.html.
It works well if url is like app.amazing.com or anything like app.amazing.com/[a-z0-9]* but as soon as there's a html extension, Nginx tries to serve this very file (exemple : app.amazing.com/test.html) and returns a 404 if it doesn't exist.
server {
listen [::]:443;
listen 443;
server_name app.amazing.com;
root /var/www/front/public;
include /etc/nginx/conf.d/expires.conf;
charset utf-8;
location / {
try_files /maintenance.html =404;
}
}
I also tried a rewrite like that:
location / {
rewrite (.*) /maintenance.html break;
}
I even tried this if-based solution, but nothing seems to work. Did I miss something?