Apache2 – Access based on IP – http password access

How to allow/deny access based on IP address. Also how to use the htpasswd file

1) Access based on IP – See lines 9 to 11


    Options Indexes FollowSymLinks
    AllowOverride AuthConfig
    AuthType Basic
    AuthName "Authentication Required"
    Require valid-user
    AuthUserFile "/var/www/html/.htpasswd"
    #Require all granted
    Order deny,allow
    Deny from all
    Allow from 10.0.0.29


2) – http password access – See lines 3 to 7
The .htpasswd file will need to be told which users it should accept. You do this issuing the following command:

1
htpasswd -c .htpasswd gmastrokostas

    Options Indexes FollowSymLinks
    AllowOverride AuthConfig
    AuthType Basic
    AuthName "Authentication Required"
    Require valid-user
    AuthUserFile "/var/www/html/.htpasswd"
    #Require all granted
    Order deny,allow
    Deny from all
    Allow from 10.0.0.29


Share Button

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload the CAPTCHA.