Nginx set an unbound domain name to prohibit access

Source: Internet
Author: User
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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.