apache — password protect your web resource only to external user

Think aboutĀ  that an IT company would like to protect their example project from Internet user,but allow their customer to access with password.however,the developer would not like to input password.

if you wanted to let people on your network have unrestricted access to a portion of your website, but require that people outside of your network provide a password, you could use a configuration similar to the following:

Require valid-user
Allow from 192.168.1
Satisfy Any

you can put the config directive into a .htaccess file or enclose the config diretive with apache Directory directive.With theĀ Satisfy Any directive the client will be granted access if they either pass the host restriction or enter a valid username and password.But please keep in mind that the config may not work if your server allow all user access by default.we should tweak the config to be more restricted.

Order Allow,Deny
AuthType Basic
AuthName “Restricted Resource”
AuthUserFile /var/users
Require valid-user

Allow from 192.168.1
Satisfy Any

[OR]

Order Deny,Allow
Deny from All
AuthType Basic
AuthName “Restricted Resource”
AuthUserFile /var/users
Require valid-user

Allow from 192.168.1
Satisfy Any

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *