Summary of Apache user authentication methods 1. basic Apache user authentication method: if user authentication is required for files in a directory such as homeftppub, httpd is used. add the following lines to the conf: optionsindexesfollowsymlinksallowoverrideauthconfigorderallow. denyallowfromall is used in the directory homeftppub to delegate Apache
Summary of Apache user authentication methods
I. basic Apache user authentication methods:
If user authentication is required for files in a directory such as/home/ftp/pub, add the following lines to httpd. conf.
<>
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 a correct user name and password pair can be provided, login access is allowed. this is a request for any address that requires 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 through a leased line, the internal Nic address is 192.168.0.1/32, now all users on the local LAN do not need to be authenticated when they want to access another WWW server on the LAN through the apache reverse proxy on the firewall through the local 163. 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. you have different permissions for the same directory and its subdirectories. only some people can access the subdirectories in one directory.
If there is a directory/home/ftp/pub/sales, there are three users: user1, user2, and user3, all of which require the user name and password to enter/home/ftp/pub, but only user1, user2 can access/home/ftp/pub/sales. put the following line down 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>
Check whether/home/ftp/pub/. htaccess is:
AuthName "shared files"
AuthType Basic
AuthUserFile/etc/. passwd
Require valid-user
Check/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