server_name

Context: server

Assigns one or more hostnames to the server block. When Nginx receives an HTTP request, it matches the Host header of the request against all of the server blocks. The first server block to match this hostname is selected.

If no server block matches the desired host, Nginx selects the first server block that matches the parameters of the listen directive (for example, listen *:80 would be a catch-all for all requests received on port 80), giving priority to the first block that has the default_server option enabled on the listen directive.

This directive accepts wildcards as well as regular expressions. In this case, the hostname should start with the ~ character.

Syntax: server_name hostname1 [hostname2...];

Examples:

server_name www.website.com; 
server_name www.website.com website.com; 
server_name *.website.com; 
server_name .website.com; # combines both *.website.com and website.com 
server_name *.website.*; 
server_name ~^(www).example.com$; # $1 = www 

You may use an empty string as the directive value in order to catch all of the requests that do not come with a Host header, but only after at least one regular name (or _ for a dummy hostname):

server_name website.com ""; 
server_name _ ""; 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.132.222