Apache Access restrictions and virtual hosting

Source: Internet
Author: User
Tags hosting

HTTPD Service access Control

1:http 's access control is divided into two main types of controls :

Client Address Restrictions

User Authorization Restrictions

Order Configuration items can be divided into two types :

Order allow from and order deny from

Allow.deny Address1 address2 first deny after allow

Deny,allowaddress1 address2 first allowed after deny

2: Modify the master configuration file

files under the vim/usr/local/httpd/conf/httpd.conf path

(1) limit the IP address of the client

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8F/5A/wKioL1jbqKOiaXGUAABmfW1oiOE487.png-wh_500x0-wm_ 3-wmp_4-s_236725499.png "title=" image 1.png "alt=" Wkiol1jbqkoiaxguaabmfw1oioe487.png-wh_50 "/>

to verify: 192.168.1.10 can 192.168.1.100, you can't .

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8F/5A/wKioL1jbqLGR0dVyAAE-MCIfOW4933.png-wh_500x0-wm_ 3-wmp_4-s_875252422.png "title=" image 2.png "alt=" Wkiol1jbqlgr0dvyaae-mcifow4933.png-wh_50 "/>

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8F/5A/wKioL1jbqMCwPzCBAAELIzpg7FY451.png-wh_500x0-wm_ 3-wmp_4-s_2197329673.png "title=" image 3.png "alt=" Wkiol1jbqmcwpzcbaaelizpg7fy451.png-wh_50 "/>

(2) Restrictions on users:

Create a user authentication data file first A dedicated HTPPASSWD tool program can be used

You must use the-C option to create a new file

Cd/usr/local/httpd

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8F/5C/wKiom1jbqM3hsyfrAAB9GenJ8Zs630.png-wh_500x0-wm_ 3-wmp_4-s_821119256.png "title=" image 4.png "alt=" Wkiom1jbqm3hsyfraab9genj8zs630.png-wh_50 "/>

Confirm user Data file: Using the cat command

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8F/5A/wKioL1jbqNuRaDqXAAAdYdZOfew560.png-wh_500x0-wm_ 3-wmp_4-s_3643016094.png "title=" image 5.png "alt=" Wkiol1jbqnuradqxaaadydzofew560.png-wh_50 "/>

To begin authorizing a user: 650) this.width=650; "Src=" Https://s1.51cto.com/wyfs02/M01/8F/5C/wKiom1jbqO7xi1TLAACI3LC7k6U906.png-wh _500x0-wm_3-wmp_4-s_1342968591.png "title=" image 6.png "alt=" Wkiom1jbqo7xi1tlaaci3lc7k6u906.png-wh_50 "/>

The service must be restarted after it is finished /usr/local/httpd/bin/apache Restart is verified as follows

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8F/5B/wKioL1jbqnmgek1dAAHMnenYHRA693.png-wh_500x0-wm_ 3-wmp_4-s_3677496913.png "title=" image 14.png "alt=" Wkiol1jbqnmgek1daahmnenyhra693.png-wh_50 "/>

3: Build the virtual host :

can be divided into 3 kinds of virtual host based on IP Port based on domain name

first of all, based on the introduction of domain names :

first prepare the Web page document for the virtual host : Create two directories benetcom and accpcom

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8F/5B/wKioL1jbqrbSpqIpAAAkl_vwmR0582.png-wh_500x0-wm_ 3-wmp_4-s_21735858.png "title=" image 15.png "alt=" Wkiol1jbqrbspqipaaakl_vwmr0582.png-wh_50 "/>

Then pour the contents of the page into the directory

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8F/5D/wKiom1jbqt3zeFcXAAAm7Xl0yxQ423.png-wh_500x0-wm_ 3-wmp_4-s_1657189725.png "title=" image 16.png "alt=" Wkiom1jbqt3zefcxaaam7xl0yxq423.png-wh_50 "/>

To Add a virtual host configuration : The main points are divided into

Listening Address : Use the Name Virtual Host to provide an IP address

Virtual Host Zone : Establish separate configuration content for each virtual host

Directory Permissions : Set access permissions for each directory, such as allowing anyone to access

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8F/5D/wKiom1jbqZ3yG9ulAADlJFv8LV8560.png-wh_500x0-wm_ 3-wmp_4-s_3011223521.png "title=" image 11.png "alt=" Wkiom1jbqz3yg9ulaadljfv8lv8560.png-wh_50 "/>

To open the configuration file for the virtual machine in the master configuration file:

Vim/usr/local/httpd/conf/httpd.conf

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8F/5D/wKiom1jbqw6Ti4qCAABDRnSPdIA557.png-wh_500x0-wm_ 3-wmp_4-s_2001298907.png "title=" image 17.png "alt=" Wkiom1jbqw6ti4qcaabdrnspdia557.png-wh_50 "/>

In addition, if you modify the directory path of the Web page to be modified in the main configuration file

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8F/5B/wKioL1jbqymxSyXeAABBmFqavd4530.png-wh_500x0-wm_ 3-wmp_4-s_2103777529.png "title=" image 18.png "alt=" Wkiol1jbqymxsyxeaabbmfqavd4530.png-wh_50 "/>

then restart the Apache service vim/usr/local/httpd/conf/httpd.conf

Start verification: 650) this.width=650; "Src=" Https://s3.51cto.com/wyfs02/M00/8F/5D/wKiom1jbq0jiYZd6AACy7uZt8sk519.png-wh_ 500x0-wm_3-wmp_4-s_1446968851.png "title=" image 19.png "alt=" Wkiom1jbq0jiyzd6aacy7uzt8sk519.png-wh_50 "/>

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8F/5D/wKiom1jbq26Rn1RhAADXiUwnFMU791.png-wh_500x0-wm_ 3-wmp_4-s_662456018.png "title=" image 20.png "alt=" Wkiom1jbq26rn1rhaadxiuwnfmu791.png-wh_50 "/>

based on IP address configuration : First there are two IP addresses 650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/ 8f/5b/wkiol1jbq4ucvouhaadlzspsd8q197.png-wh_500x0-wm_3-wmp_4-s_2495550459.png "title=" image 21.png "alt=" Wkiol1jbq4ucvouhaadlzspsd8q197.png-wh_50 "/>

To modify a virtual host configuration file:

content under vim/usr/local/httpd/conf/extra/httpd-vhosts.conf

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8F/5D/wKiom1jbq6zxpHAxAADp4flbdmo034.png-wh_500x0-wm_ 3-wmp_4-s_1952617132.png "title=" image 22.png "alt=" Wkiom1jbq6zxphaxaadp4flbdmo034.png-wh_50 "/>

Restart Verification After completion: Access 192.168.1.1 and 192.168.1.2

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8F/5B/wKioL1jbq8qyGzgHAAChhViZdVc621.png-wh_500x0-wm_ 3-wmp_4-s_2974457508.png "title=" Picture 23.png "alt=" wkiol1jbq8qygzghaachhvizdvc621.png-wh_50 "/>650" this.width=650 ; "Src=" Https://s5.51cto.com/wyfs02/M00/8F/5B/wKioL1jbq-jQvNxiAAC0AB1OGbs796.png-wh_500x0-wm_3-wmp_4-s_ 390925354.png "title=" image 24.png "alt=" wkiol1jbq-jqvnxiaac0ab1ogbs796.png-wh_50 "/>

Finally, the port is set

the first thing to do IP Address port configuration by default , You can add a 8080

To configure a virtual host file:

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/8F/5D/wKiom1jbrAXzYGtrAACCZud85pg429.png-wh_500x0-wm_ 3-wmp_4-s_4088687083.png "title=" image 25.png "alt=" Wkiom1jbraxzygtraacczud85pg429.png-wh_50 "/>

Then add the listening port in the master profile

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8F/5D/wKiom1jbrB-TVOusAAA3-tpSXkU472.png-wh_500x0-wm_ 3-wmp_4-s_3801744626.png "title=" image 26.png "alt=" Wkiom1jbrb-tvousaaa3-tpsxku472.png-wh_50 "/>

after Restart Apache Service for verification: 650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8F/5D/ Wkiom1jbrdrgxj-naaczcpxuozg149.png-wh_500x0-wm_3-wmp_4-s_1865643990.png "title=" image 27.png "alt=" Wkiom1jbrdrgxj-naaczcpxuozg149.png-wh_50 "/>650) this.width=650;" Src= "https://s2.51cto.com/wyfs02/M00/8F/5D/ Wkiom1jbrfegllozaac3rv9c9w4731.png-wh_500x0-wm_3-wmp_4-s_3929315051.png "title=" image 28.png "alt=" Wkiom1jbrfegllozaac3rv9c9w4731.png-wh_50 "/>


This article is from the "Apache" blog, make sure to keep this source http://xiaorenwutest.blog.51cto.com/12754924/1911550

Apache Access restrictions and virtual hosting

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.