Pages

Friday, 19 August 2016

nginx and the default server dilema

Something to look out for when setting up nginx is that there are a fair few misleading default configurations out there - for example when working with SNI's always ensure that you have defined a default server - otherwise the first server block will take this role!

To make things even worse quite often you will see server blocks such as:

server{
   listen 1.2.3.4:80;
   server_name _;
   ...
}

or

server{
   listen 1.2.3.4:80;
   server_name localhost;
   ...
}

Neither of these will act as a default server - rather you must use 'default_server' with the 'listen' directive for example:

server{
   listen 1.2.3.4:80 default_server;
   server_name _;
   ...
}

No comments:

Post a Comment