Linux under Nginx to prevent others to bind the domain name

Source: Internet
Author: User
Tags bind


Nginx's default virtual host takes effect when a user accesses through IP or through a domain name that is not set (such as when someone points his own domain name to your IP).

For example, when someone accesses your website via IP or unknown domain name, you want to suppress any valid content and return 444 to him.
At present, many domestic computer rooms are required to shut down the main web site, to prevent the North shore of the domain name point to cause trouble.

You can set it this way:

1. Direct 301 or return 444

server {
Listen default_server;
server_name _;
return 444;
}

2. You can also collect these traffic, import to their own website, as long as the following jump settings can be:

server {
Listen default_server;
server_name _;
return http://www.111cn.net $request _uri;
}

Two solutions: Nginx's default virtual host takes effect when a user accesses via IP, or through a domain name that is not set (such as when someone points his own domain name to your IP).

Set up prohibit IP and unbound domain name access

Add the following code to the configuration file (whole paragraph)

① return 500 error

server {
Listen default;
server_name _;
return 500;
}

② jump to their own domain name home

Server {
        listen default;
         server_name _;
        Rewrite ^ (. *) http://www.111cn.net permanent;
}
Step3 nginx
This way, the domain name that is not bound in Nginx and IP access will return 500 errors or jump to my domain first

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.