In case you need to restrict a particular virtual path on Apache, you need to add following code to your httpd.conf or apache2.conf file:
<Location "/bin/path">
AuthUserFile C:/Apache/users
AuthName "Restricted Files"
#AuthGroupFile /dev/null
AuthType Basic
Require valid-user
</Location>
AuthUserFile- is the location of password file. You can define your custom path. The value provided here is just for illustration purpose. For Linux it can look like - "/etc/users"
If you want to provide access to usergroups then you can use AuthGroupFile, otherwise you should comment it.
AuthType- Various methods of authentication are available. It may be any of - None, Basic, Digest and Form.
AuthType Basic is not a secure way for authorization. Instead use Digest method with SSL.
You can also authenticate users from LDAP or DB. Refer the documentation at- https://httpd.apache.org/docs/2.4/howto/auth.html
<Location "/bin/path">
AuthUserFile C:/Apache/users
AuthName "Restricted Files"
#AuthGroupFile /dev/null
AuthType Basic
Require valid-user
</Location>
AuthUserFile- is the location of password file. You can define your custom path. The value provided here is just for illustration purpose. For Linux it can look like - "/etc/users"
If you want to provide access to usergroups then you can use AuthGroupFile, otherwise you should comment it.
AuthType- Various methods of authentication are available. It may be any of - None, Basic, Digest and Form.
Creating users for access- Run below command
htpasswd -c /etc/mysite/users mysite-new-user
AuthType Basic is not a secure way for authorization. Instead use Digest method with SSL.
You can also authenticate users from LDAP or DB. Refer the documentation at- https://httpd.apache.org/docs/2.4/howto/auth.html
No comments:
Post a Comment