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

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
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?


Solved it by using nginx.

    location /folder/ {
    proxy_pass http://localhost:8080/folder/;
    satisfy  any;
    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 agree to our terms of service, privacy policy and cookie policy

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