Hi,
You might be aware that if a DNS request point your nginx server.
and this later do not have a server
rule for it , nginx will server anyway the first server found in your config file, WTF !
So I’ve found https://stackoverflow.com/a/23281442
server {
listen 80 default_server;
server_name everythingelse;
error_page 404 /404.html;
# Everything is a 404
location / {
return 404; #return the code 404
}
# link the code to the file
location = /404.html {
#EDIT this line to make it match the folder where there is your errors page
#Dont forget to create 404.html in this folder
root /var/www/nginx/errors/;
}
}
But this is not working !
I made one of my domain pointing to this nginx server, and he still server another site aka server
For httpS for http nothing appear…
Thanks.
What is it that you want to happen? Sorry it is a bit unclear in your post.
I wanted to have a
default server
that catch ~wrong DNS query to the serverSolution
I don’t know how to link to my previous lemmy post, so here it is again
server { listen 443 ssl; server_name _; ssl_certificate /etc/nginx/ssl/catchall.crt; ssl_certificate_key /etc/nginx/ssl/catchall.key; error_page 404 /404_CatchAll.html; # Everything is a 404 location / { return 404; } location /404_CatchAll.html {root /var/www/html/;} }
Just guessing, but should it be pointing at 404.txt, not /404.txt
line 5 you mean ?
error_page 404 /404.html; #this one ?
ok I’ve found something that ~works !
server { listen 443 ssl; server_name _; ssl_certificate /etc/nginx/ssl/catchall.crt; ssl_certificate_key /etc/nginx/ssl/catchall.key; error_page 404 /404.html; #at /var/www/html/ location /404.html {internal;} return 404; }
so i get the default 404 html from nginx. but not the one that I specified
error_page 404 /404.html;
any ideas ?The full working code:
server { listen 443 ssl; server_name _; ssl_certificate /etc/nginx/ssl/catchall.crt; ssl_certificate_key /etc/nginx/ssl/catchall.key; error_page 404 /404_CatchAll.html; # Everything is a 404 location / { return 404; } location /404_CatchAll.html {root /var/www/html/;} }