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

Reprint: Http://m114.org/nginx%E7%A6%81%E6%AD%A2%E9%80%9A%E8%BF%87ip%E6%9C%AA%E7%BB%91%E5%AE%9A%E5%9F%9F%E5%90%8D%E8 %ae%bf%e9%97%ae%e6%9c%8d%e5%8a%a1%e5%99%a8/

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.