How does one prevent malicious resolution and prohibit the use of IP addresses to access Apache settings of the website?

Source: Internet
Author: User

Generally, websites can be accessed by domain names and IP addresses. Your website can be accessed directly through an IP address. This is no problem, but it may cause some risks:
Because the search engine will also include the pages of your IP address, the same page search engine will record the pages, resulting in a higher page weight than a single index.
The possibility of malicious domain name pointing. Do you still remember the google.com. sb incident last year or the year before? The domain name google.com. sb was maliciously directed to Baidu, and later confirmed that the domain name google.com. sb was maliciously pointed to by a third party, not by Google. Of course this is just a joke, but if someone maliciously uses another domain name to resolve your IP address, then your website will be accessible through another domain name. What will happen next? If the domain name is unfriendly, for example, if it has been directed to an illegal website, it is easy to cause search engine penalties and the IP address is associated. Even if there is no problem with the domain name, the traffic will be hijacked to another domain name, thus being banned by the advertising alliance.
How can this problem be solved? The most direct method is to allow users to access the website only through the domain name, but not through the IP address. This can be implemented by modifying the Apache configuration file httpd. conf. The following is the implementation of the station:

1.  NameVirtualHost 121.*.*.* 
2.  <VirtualHost 121.*.*.*> 
3.  ServerName 121.*.*.* 
4.  <Location /> 
5.  Order Allow,Deny 
6.  Deny from all 
7.  </Location> 
8.  </VirtualHost> 
9.  <VirtualHost 121.*.*.*> 
10.DocumentRoot /var/www/nowamagic/ 
11.ServerName www.nowamagic.net 
12.</VirtualHost> 
13.<VirtualHost 121.*.*.*> 
14.DocumentRoot /var/www/nowamagic/ 
15.ServerName nowamagic.net 
16.</VirtualHost> 
The first part of the code is to reject any access requests directly through the IP address 121. *. If you use 121. *. * for access, a message is displayed, prompting you to reject the access.
The second part of the code is to allow access through the http://www.nowamagic.net/this domain name, the main directory points to/var/www/nowamagic/(here the Server OS is CentOS ).
The third part of the code is to allow access by domain names without www. You should be able to write it together with the above Code.
Record it here to make it easy for you to stick to it later.
 

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.