docker-nginx-basic-auth icon indicating copy to clipboard operation
docker-nginx-basic-auth copied to clipboard

simple Basic Authentication for localhost

Open digitalkaoz opened this issue 4 years ago • 0 comments

i dont want to secure a secondary container, but instead protect a served folder locally like this:

server {
    server_name example.com;
    root /var/www/web_root/;
    index index.html;

    auth_basic "Restricted";
    auth_basic_user_file auth.htpasswd;
}

any way we can make this happen? currently its really just a proxy (resulting in an endless loop) when started with localhost:

FORWARD_HOST=127.0.0.1

server {
 listen 80 default_server;

 location / {
     auth_basic              "Restricted";
     auth_basic_user_file    auth.htpasswd;

     proxy_pass                          http://127.0.0.1:80;
     proxy_read_timeout                  900;
 }
}

currently i am solving it like this:

server {
 listen 80 default_server;
 auth_basic              "Restricted";
 auth_basic_user_file    auth.htpasswd;
 root /usr/share/nginx/html;
 index index.html;
}
FROM beevelop/nginx-basic-auth

COPY html_files /usr/share/nginx/html
COPY nginx.conf /opt/auth.conf

it works, but it would be cool if it works without local files and custom containers. Just an idea...

digitalkaoz avatar Aug 30 '21 07:08 digitalkaoz