This article mainly introduces about Nginx set unbound domain name Forbidden Access, has a certain reference value, now share to everyone, have the need for friends can refer to
By default, Nginx allows direct access to the Web site directly as an IP, or through an unassigned domain name (such as someone pointing his or her own domain to your server IP). It's so easy to expose some Web sites on the server, so how do we set Nginx to prohibit these behaviors?
server { listen default_server; server_name _; return 404;}
When an unbound domain name points to your server, the virtual host is not matched to the domain name you configured, and then it returns 404 directly.
listen 80 default_server
: Specifies that the server configuration segment is the default host for Port 80, that is, when the unbound domain name points to your server, it will not match the virtual host domain name you configured, and the virtual host is used by default.
server_name _
: _
This can be replaced with any other invalid character or invalid domain name, indicating that the server configuration will not be properly accessed.
return 404
: Indicates that a 404 error is returned directly.
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!