Article title: Apache user authentication method summary. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Author: Wu Aiting
I. basic Apache user authentication methods:
If user authentication is required for files in a directory such as/home/ftp/pub
Add the following rows
<>
Options indexes followsymlinks
Allowoverride authconfig
Order allow, deny
Allow from all
<>
Use it in the/home/ftp/pub directory to place the file. htaccess. the content is as follows:
Authname "shared files"
Authtype basic
Authuserfile/etc/. passwd
Require valid-user
Use the program htpasswd with Apache to generate the file/etc/. passwd. each line has one user name: password
As long as the correct user name and password pair are provided, login access is allowed. this is for any address.
All requests require user name and password authentication.
2. authentication is required for some CIDR blocks or addresses.
If the network segment of the company's LAN is 192.168.0.0/24 and a firewall is connected to the Internet,
The IP address of the internal Nic is 192.168.0.1/32, and now all
The apache reverse proxy on the firewall needs to be authenticated when accessing another WWW server on the LAN, while the local
Users on the LAN do not need to be authenticated. You can put the following in httpd. conf:
<Directory/home/ftp/pub>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Order deny, allow
Deny from 192.168.0.1
</Directory>
Put the following in/home/ftp/pub/. htaccess:
AuthName "shared files"
AuthType Basic
AuthUserFile/etc/. passwd
Require valid-user
Satisfy any
3. have different permissions for the same directory and its subdirectories. only some people can access
Subdirectory.
If there is a directory/home/ftp/pub/sales, there are three users user1, user2, user3 all need the user name
And password enter/home/ftp/pub, but only user1, user2 can enter/home/ftp/pub/sales.
Move 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.