Apache User authentication Method Summary (reprint) _php
Source: Internet
Author: User
Keywords summary reprint method authentication user catalogue ALLOWETC
Apache
Apache User authentication Method Summary
A. Basic Apache user authentication method:
If user authentication is required for 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
<>
Use the directory/home/ftp/pub to decentralize the file. htaccess, the contents are as follows:
AuthName "Shared Files"
AuthType Basic
authuserfile/etc/.passwd
Require Valid-user
Use the program with Apache htpasswd generate file/etc/.passwd, one user name per line: password
Login access is allowed as long as the correct user name and password pair is provided, which is required to provide user name and password authentication for any address request.
Two. Authentication is required for some network segments or addresses.
If the LAN segment of the company is 192.168.0.0/24, and there is a firewall dedicated to the Internet, the address of the internal network card is 192.168.0.1/32, You now want to require authentication 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 do not need authentication. Can be put in 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 for the same directory and the subdirectories under it, and only some people can access subdirectories under a directory.
If there is a directory/home/ftp/pub/sales, there are three users user1,user2,user3 need username and password to enter/home/ftp/pub, but only user1,user2 can enter/home/ftp/pub/ Sales. Then put the following line 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>
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.