NGINX - Basics
NGINX uses the following logic when determining which virtual server should serve a specific request:
1. Match the IP address and port to the listen directive.
2. Match the Host header field against the server_name directive as a string.
3. Match the Host header field against the server_name directive with a wildcard at the beginning of the string.
4. Match the Host header field against the server_name directive with a wildcard at the end of the string.
5. Match the Host header field against the server_name directive as a regular expression.
6. If all the Host headers match fail, then direct to the listen directive marked as default_server.
7. If all the Host headers match fail and there is no default_server, direct to the first server with a listen directive that satisfies step 1.
TIP
sed -i .bak '/^\s*#/d;/^S/d' nginx.conf
First backup -- (-i .bak)
'/^\s*#/d - search for lines start with '#' and asterisks represent any amount of white space then delete
^S/d - Find while spaces and delete