Apache 2.4 Configuration httpd: Add domain to prohibit IP access to website

Source: Internet
Author: User
Tags website domain names

Apache 2.4 Configuration httpd: Add domain to prohibit IP access to website

In general, websites can be accessed using domain names and IP. Your website can be directly accessed by IP, originally this is not a problem, but there are some hidden dangers: Because the search engine will also include your IP address of the page, so the same page search engine will be repeated, resulting in page weight than a single inclusion high. A malicious domain name may: Remember the Google.com.sb event? GOOGLE.COM.SB This domain name is malicious to Baidu, later confirmed GOOGLE.COM.SB this domain for third party malicious point, not Google. Of course, this is only a joke, but if someone maliciously uses another domain name to resolve to your IP, then your website can be accessed by someone else's domain name. What happens next? If the domain name is unfriendly domain name, such as once pointed to illegal website, easy to trigger search engine penalty, associated IP was implicated. Even if the domain name is not a problem, but traffic will be hijacked to another domain name, which was blocked by the advertising alliance.

How to solve this problem? The most straightforward approach is to allow users to access the site only through domain names, not directly through IP. This can be implemented by modifying the Apache configuration file httpd.conf. This is the 2.2 version of the configuration method: currently confirmed invalid!
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/8B/4A/wKiom1hI9ZHAwWPCAACc9dn0wzI346.png-wh_ 500x0-wm_3-wmp_4-s_2518377765.png "title=" 20160616040109992.png "style=" Float:none; "alt=" Wkiom1hi9zhawwpcaacc9dn0wzi346.png-wh_50 "/>

Apache 2.4 version, can not use namevirtualhost, then how to configure the domain name, how to prohibit IP access to the site to prevent malicious parsing?

The answer is here: the correct way to edit the httpd.conf file

ServerAdmin [email protected]//change to: ServerAdmin [email protected]//your own mailbox

#ServerName www.example.com:80//remains as is, one IP binds multiple website domain names and prohibits IP access to the site, and does not need to be changed here

DocumentRoot "/var/www/html"//Change to: #DocumentRoot "/var/www/html/"//disable this file, otherwise you will always jump to this, this is the so-called main domain point to the directory

Next is the most critical: (Editor can not insert code, forgive me!) )


650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/8B/4A/wKiom1hI9ZGg4U5KAADDRdPrMlE421.png-wh_500x0-wm_3 -wmp_4-s_2717933628.png "title=" 20160616040052986.png "style=" Float:none; "alt=" Wkiom1hi9zgg4u5kaaddrdprmle421.png-wh_50 "/>

The key is "*:80" here, my understanding is: Listen to this IP port 80, if you hear "www.lu-kou.com" point to the "/var/www/html/lu-kou" file, here are double quotes Oh. If you hear "512.40.2120.171 (your site's IP)" then point to "error page"

OK, here, a single IP configuration domain name and prohibit IP access to the site is resolved.

If multiple domain names correspond to multiple IPs, please go to the original article page to see it! You can download http://www.lu-kou.com/uploadfile/2016/0616/20160616034700494.zip!


This article from "11726068" blog, declined reprint!

Apache 2.4 Configuration httpd: Add domain to prohibit IP access to website

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.