Folder password with Apache and Nginx for external connections

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?

user3549596

Posted 2016-10-02T20:41:16.350

Reputation: 177

Answers

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;
    }

user3549596

Posted 2016-10-02T20:41:16.350

Reputation: 177