Nginx. Parameter default_server

The default_server parameter defines the default server to which a client request will be sent in which the host field is empty or an unknown domain is specified in it. For example, when a client opens the server IP address in a browser, or when the server has several domains, for example, ixnfo.com, test1.ixnfo.com, test2.ixnfo.com, but not all domains are specified in the ngixn configuration.

By default, if the default_server parameter is not specified, then the default server will be the first one specified in the configuration, but it can also be explicitly specified, for example:

server {
    listen 80 default_server;
    #listen [::]:80 default_server;
    server_name test.ixnfo.com;
    ...
}
 
server {
   listen 443 ssl default_server;
   #listen [::]:443 ssl default_server;
   server_name test.ixnfo.com;
   ...
}

I note that in versions older than Nginx 0.8.21, instead of the parameter “default_server” the parameter “default” was specified. Check the Linux version of Nginx with the command:

nginx -v

See also my article:
Redirect HTTP to HTTPS in Nginx

Leave a comment

Leave a Reply