My nginx.conf
file doesn’t contain a server
block inside the http
block so I assume it uses a default server on port 80. However, I’ve been unable to find confirmation of this.
I’m wondering if I now add this server
block inside my http block:
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
}
Does my assumed default server still exist or has my new server overridden it to now be the default?
CodePudding user response:
If you provide no default explicitly (using the "default_server" parameter in the listen directive) nginx will use either the server matching the one named in the Host: header of the request or, lacking that, the first one it finds in your config.
You can read more about how requests are handled by nginx here: