: This article mainly introduces how to disable access to the server through ip addresses on nginx. you can only access the server through the domain name. if you are interested in the PHP Tutorial, refer to it.
To prevent unauthorized domain names from being resolved to their own server ip addresses, the server may be disconnected from the network. in nginx, you must disable access to the server through ip addresses and only access through domain names. The most important thing is to add such a line in the server settings: Listen 80 default; the default parameter next to it indicates that this is the default VM. For example, if you want to disable the display of any valid content when someone accesses your website through an ip address or an unknown domain name, you can return 500 to someone else. The details are as follows: Server {Listen 80 default; Server_name _; Return 500;} of course, according to the above settings, it is indeed impossible for others to access the Server through an ip address, however, one or more real domain names to be accessed should also be opened, and the configuration should be set as follows: Server {Linten 80; Server_name www.941db.com; (take the world Sea for example) ...........}
The above describes how to disable access to the server through ip addresses on nginx, and only access through domain names, including some content. I hope to be helpful to anyone interested in PHP tutorials.