1

I want to secure a folder with username and password. The password should only be needed when accessing the server from outside its network. (192.168.0.0/24)

I tried using .htaccess, but it ignores my satisfy any.

AuthType Basic
AuthName "pw"
AuthUserFile /var/www/folder/.htpasswd
Require valid-user
Order allow,deny
Allow from 192.168.0.0/255.255.255.0
satisfy any

I am not sure if the Allow from line is correct. Nginx forwards the headers to Apache, so the "real IP" is seen from Apache too.

Would the password protection easier with nginx?

0

Solved it by using nginx.

    location /folder/ {
    proxy_pass http://localhost:8080/folder/;
    satisfy  any;
    allow  192.168.0.0/24;
    deny   all;
    auth_basic            "pw";
    auth_basic_user_file  /var/www/folder/.htpasswd;

    include /etc/nginx/proxy_params;
    }

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.