I had both production (www.myexample.com) and development (dev.myexample.com) on a single server, using server blocks and separate directories, with both listening on port 80. This worked fine.
Now I have installed the SSL certificate and enabled SSL mode in the site config file. At the same time I changed the listening port from 80 to 443, so the site should not respond on port 80, only on port 443. The development site is still running as it was.
Now it appears that in stead of an error, I get the development site when I connect to http://www.myexample.com.
To fix this problem I added a real "default" server block (server_name set to _) and pointing to a directory which contains no files.
Is there a better way? If I want a real default web site, I don't want it to be shown for a known hostname. I am guessing I have to create a server block listening fr www.myexaple.com:80 and configure it to somehow reject all page requests, but how?
How can I completely stop responding to any requests for a site I do not host?
default_server
after the listen directive port / IP address. It is not defined by the use of an invalid host name.return 404
orreturn 444
instead. But in general it's the only right way