How to enable apache to only allow access by domain names and disable IP addresses

Source: Internet
Author: User
To allow apache to only allow access by domain names, and to prohibit implementation of IP addresses, use apache to build a WEB server. how can we allow users to access the server only through the specified domain name instead of the IP address of the server, through searching, there are two methods to achieve this. Both are modifying httpd. conf file... to allow apache to only allow access by domain names, and to prohibit implementation of IP addresses, use apache to build a WEB server. how can we allow users to access the server only through the specified domain name instead of the IP address of the server, through searching, there are two methods to achieve this. Both are modifying httpd. conf file. The following is an example. Method 1: at the end of the httpd. conf file, add the following code NameVirtualHost 211 .*.*.* Server Name 211 .*.*.* Order Allow, Deny from all DocumentRoot "c:/web" ServerName tuan.coo8.com Note: the blue part is used to reject the request directly through 211. *. *. * for any access request from this IP address, if you use 211. *. *. * access is denied. The red part is allowed to use the http://tuan.coo8.com/domain name, the main directory is directed to c://web (Here we assume your website's root directory is c:/web) Method 2: in httpd. add the following code NameVirtualHost 211 to the end of the conf file. *. *. * DocumentRoot "c:/test" ServerName 211 .*.*.* DocumentRoot "c:/web" ServerName http://tuan.coo8.com Note: the blue part passes through 211. *. *. * direct access requests from this IP address point to the c:/test Directory. this can be an empty directory or a home page file, such as index, can be created. hmtl. the content of the first file can be a declaration, indicating that it cannot be accessed directly through an IP address. Note: 1. if you copy and paste the file directly, it may contain Chinese spaces. remove these unnecessary spaces. 2. if server load balancer is used, do not enter an Internet IP address for the restricted IP address. enter an intranet IP address.
 
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.