Nginx is forbidden to access the server via IP, unbound domain name

Source: Internet
Author: User

These days to view the CNZZ statistics backstage See, my IP was two unknown domain name binding, in order to avoid being harmonious by the celestial,
Can be set on Nginx to prohibit IP access to the server, only through the binding domain name access (at the same time set the unbound domain name return 500 error or jump to my drop domain name home)
method is relatively simple,
Open nginx.conf

Step1 Binding website Domain name

Add a domain name to the server segment server_name row

server {        a;        server_name m114.org www.m114.org;        Index index.html index.htm index.php;         /data/htdocs/www;}

Step2 setting forbidden IP and unbound domain name access
Add the following code to the configuration file (entire paragraph)
① return 500 error

server {        default;        server_name _;         return  - ;}

② jump to your own domain homepage

server {        default;        server_name _;         ^ (. *) http://m114.org permanent;}

Step3 Restart Nginx

In this way, the domain name and IP access not bound in Nginx will return 500 error or jump to my domain home page

Nginx is forbidden to access the server via IP, unbound domain name

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.