Nginx’s default virtual host takes effect when the user accesses it via IP or through an unset domain name (such as someone pointing his own domain name to your server’s ip
For example, when someone visits your website through ip or an unknown domain name, you want to disable the display of any valid content, you can return it to 500.
1 2 3 4 |
server { listen 80 default; return 500; } |
You can also collect these traffic and import it into your own website. Just make the following jump settings:
1 2 3 4 |
server { listen 80 default; rewrite ^(.*) //www.jb51.net permanent; } |
This article was first published by V on 2018-10-04 and can be reprinted with permission, but please be sure to indicate the original link address of the article :http://www.nginxer.com/records/set-the-default-virtual-host-for-nginx-empty-host-header-default-host-header/