Link to home
Start Free TrialLog in
Avatar of Ludwig Diehl
Ludwig DiehlFlag for Peru

asked on

Apache Location Directive

Hello everyone!.

I am trying to configure my apache server so only some locations have authentication. Currently I have this:

<VirtualHost *:443>
    Header set Access-Control-Allow-Origin "*"
    ServerName mydomain
    DocumentRoot /var/www/ws
    <Directory /var/www/ws/>
        AllowOverride All
        Allow from all
        Options all
        Require all granted
    </Directory>
    <Location "/">
        AuthType Basic
        require valid-user
        AuthUserFile /var/www/.htpasswd
        AuthName "Authorization Required"
        satisfy any
        deny from all
        allow from 192.168.10
        allow from 172.16.10
    </Location>
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/apache.crt
    SSLCertificateKeyFile /etc/ssl/certs/apache.key
    SSLCertificateChainFile /etc/ssl/certs/apache.crt
    LogLevel debug
    ErrorLog /var/www/ws/logs/error.log
    TransferLog /var/www/ws/logs/access.log
    php_value include_path .:/usr/share/pear:/var/www/ws
    Alias /ws /var/www/ws
</VirtualHost>

Open in new window


However every locations  needs authentication. I want something like this:

<VirtualHost *:443>
    Header set Access-Control-Allow-Origin "*"
    ServerName mydomain
    DocumentRoot /var/www/ws
    <Directory /var/www/ws/>
        AllowOverride All
        Allow from all
        Options all
        Require all granted
    </Directory>
    <Location "/">
        AuthType Basic
        require valid-user
        AuthUserFile /var/www/.htpasswd
        AuthName "Authorization Required"
        satisfy any
        deny from all
        allow from 192.168.10
        allow from 172.16.10
    </Location>
    <Location "/services/location1/*">
        satisfy any
        Allow From All
    </Location>
    <Location "/services/location2/*">
        satisfy any
        Allow From All
    </Location>
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/apache.crt
    SSLCertificateKeyFile /etc/ssl/certs/apache.key
    SSLCertificateChainFile /etc/ssl/certs/apache.crt
    LogLevel debug
    ErrorLog /var/www/ws/logs/error.log
    TransferLog /var/www/ws/logs/access.log
    php_value include_path .:/usr/share/pear:/var/www/ws
    Alias /ws /var/www/ws
</VirtualHost>

Open in new window



Any ideas?. Is it possible to do this using .htaccess?
ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Poster seems to have stopped posting.