Set the default virtual host (empty host header default host header) for nginx

  • 2020-05-06 12:13:56
  • OfStack

The most important thing is to add this line in the server Settings:
listen 80 default;
The following default parameter indicates that this is the default virtual host.

This setting is very useful.
For example, when someone accesses your website through ip or unknown domain name, and you want to disable any valid content, you can return him 500.
At present, a lot of domestic computer rooms are required to close the site host empty host head, to prevent the record of the domain name pointing to cause trouble. You can set it like this:
 
server { 
listen 80 default; 
return 500; 
} 

You can also collect this traffic and import it to your own website by simply making the following jump Settings:
 
server { 
listen 80 default; 
rewrite ^(.*) //www.jb51.net permanent; 
} 

Related articles: