To set the configuration file disableip.conf:
server {
listen 80;
server_name _;
return500;
}
This is the final use of the configuration file, is also found on the Internet, one of the common configuration, initially the Conf file in the Sites-available folder, trying to use a variety of parameters are not working, and eventually try to put disableip.conf files into the CONF.D folder , this is because in the nginx.conf file:
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
The first reference is the CONF.D path under the configuration file, the disableip.conf file into the Conf.d folder to make this server
at the forefront, the rule is first applied, the modification is completed after the restart Nginx ( service nginx restart
), the following test:
- Enter the IP address directly
- Enter the domain name
The implementation of Nginx prohibit IP direct access to the site, only allowed through the set of domain name access.
Set Nginx prohibit IP direct access, only through the specified domain name access