Because of the record in China, all servers are prohibited from using IP to access the site. Otherwise, if you allow the use of IP access to the site, that casual resolution of a domain name to the IP, access to the domain name can open the site. This is a great risk! Nginx can be very convenient to solve this problem, small rookie to discuss with you.
Because of the record in China, all servers are prohibited from using IP to access the site. Otherwise, if you allow the use of IP access to the site, that casual resolution of a domain name to the IP, access to the domain name can open the site. This is a great risk! Nginx can be very convenient to solve this problem, small rookie to discuss with you.
As a configuration entry below, you can set up to allow access to the Web site using IP.
Copy Code code as follows:
server {
Listen 80;
SERVER_NAME "";
}
This is equivalent to binding an empty host header, so any host head, as long as the IP can open the site.
If you need to nginx prohibit the use of IP access sites, you can define the following hosts to discard these requests:
Copy Code code as follows:
server {
Listen 80;
SERVER_NAME "";
return 444;
}
Here, we set the host name to be an empty string to match a request that does not define the "host" header, and returns a Nginx-specific, non-HTTP standard return code 444, which can be used to close the connection.
Starting with version 0.8.48, this has become the default setting for host names, so you can omit server_name "", which is the following configuration:
Copy Code code as follows:
server {
Listen 80;
return 444;
}