Apache User authentication Method Summary (reprint)

Source: Internet
Author: User
Tags ftp require valid access firewall
Total Apache Apache user authentication method

A. Basic Apache user authentication method:

If you need to authenticate a file in a directory such as/home/ftp/pub, add the following line to the httpd.conf
<>
Options Indexes FollowSymLinks
AllowOverride authconfig
Order Allow,deny
Allow from all

<>
Used in the directory/home/ftp/pub decentralized files. htaccess, the contents are as follows:
AuthName "Shared Files"
AuthType Basic
authuserfile/etc/.passwd
Require Valid-user

Generate file/etc/.passwd with a program htpasswd with Apache, one user name per line: password

As long as you can provide the correct username and password pairs, you allow login access, this is for any address requests are required to provide user name and password authentication.

Two. For some network segment or address requirements certification.

If the company LAN segment is 192.168.0.0/24, and there is a firewall dedicated to the Internet, the internal network card address for 192.168.0.1/32, You now want authentication to be required for all access to another WWW server on the LAN by dialing local 163 through the Apache reverse proxy on the firewall, while users on the local LAN are not required to authenticate. Can be placed in the httpd.conf:
〈directory/home/ftp/pub>
Options Indexes FollowSymLinks
AllowOverride authconfig
Order Deny,allow
Deny from 192.168.0.1
〈/directory>

And put in the/home/ftp/pub/.htaccess:
AuthName "Shared Files"
AuthType Basic
authuserfile/etc/.passwd
Require Valid-user
Satisfy any

Three. There are different permissions to the same directory and the subdirectories under it, and only some people can access subdirectories in one directory.
If there is a directory/home/ftp/pub/sales, there are three users user1,user2,user3 need username and password to enter the/home/ftp/pub, but only user1,user2 can enter the/home/ftp/pub/ Sales. Then put the line below to httpd.conf

〈directory/home/ftp/pub>
Options Indexes
AllowOverride authconfig
Order Allow,deny
Allow from all
〈/directory>

〈directory/home/ftp/pub/sales>
Options Indexes
AllowOverride authconfig
Order Allow,deny
Allow from all
〈/directory>

and see/home/ftp/pub/.htaccess as:
AuthName "Shared Files"
AuthType Basic
authuserfile/etc/.passwd
Require Valid-user

And look at/home/ftp/pub/sales/.htaccess.
AuthName "Shared Files"
AuthType Basic
authuserfile/etc/.passwd
Authgroupfile/etc/.salesgroup
Require group manager

And the file/etc/.passwd content is:
User1:passwd1
User2:passwd2
User3:passwd3

And the file/etc/.salesgroup content is:
Manager:user1 User2


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.