Hello,
perhaps it is a stupid question, but is it possible to have an authentication for the Web Interface (called CGI, right?) ?
I tried the steps from here ( https://hub.docker.com/r/tiredofit/backuppc/ ) by adding these Container Variables
NGINX_AUTHENTICATION_TYPE=BASIC
NGINX_AUTHENTICATION_BASIC_USER1=backuppc
NGINX_AUTHENTICATION_BASIC_PASS1=backuppc
which works perfectly fine until I stop and restart the docker container, then it fails with this log message repeating continuously (full log after restart attached)
[42m[INFO][49m ** [nginx] Starting nginx 1.19.2
nginx: [emerg] "auth_basic" directive is duplicate in /etc/nginx/conf.d/default.conf:4
Any suggestions?
-- Edit --
I figured out, at every restart the following 2 lines are added again to /etc/nginx/conf.d/default.conf
auth_basic "Please login";
auth_basic_user_file /etc/nginx/nginx.conf.d/authentication/basic_authorized_users;
Not sure where its coming from, havn't found the startup script yet.
-- Edit 2 --
Also in the file /etc/nginx/nginx.conf.d/authentication/basic_authorized_users an new entry for the user and the password is generated every startup id the Container Variables aboth are set. I did some further digging in the used nginx container but didn't find a solution.
-- WORKAROUND --
My workaround now is to manually add the users and the authentication method within the container after the first start by running lines 170 and 171 from https://github.com/tiredofit/docker-nginx/blob/ba1e3b4c81a5a29aa427ba37f6242c0e06d78053/install/etc/cont-init.d/10-nginx#L170-L171 manually
htpasswd -b -n backuppc backuppc >>/etc/nginx/nginx.conf.d/authentication/basic_authorized_users
sed -i '/ server {/a\ \ \ auth_basic "'"Please login"'";\n\ \ \ auth_basic_user_file /etc/nginx/nginx.conf.d/authentication/basic_authorized_users;' /etc/nginx/conf.d/*.conf
This works fine for running and restarting the container. BUT reconfiguring the container removes (ofc) the changes. I tried mounting the whole etc/nginx/ folder to unraid, but this does not work. nginx within the container then won't create its config (don't know why).
To keep the user and authentication settings even after changing the container I did the following steps (prob not the best solution, but it works for me right now).
1) Copying the /conf.d and /authentication folders to my unraid share (paths may be changed or folders created manually)
docker cp --follow-link backuppc:/etc/nginx/nginx.conf.d/authentication /mnt/user/appdata/backuppc/nginx/nginx.conf.d/authentication
docker cp --follow-link backuppc:/etc/nginx/conf.d /mnt/user/appdata/backuppc/nginx/conf.d
2) reconfiguring the docker container and adding these two mounts
Host Path: /mnt/user/appdata/backuppc/nginx/conf.d/
Container Path: /etc/nginx/conf.d
Host Path: /mnt/user/appdata/backuppc/nginx/nginx.conf.d/authentication/
Container Path: /etc/nginx/nginx.conf.d/authentication
--
If anyone has a better suggestion, I would love to hear it!
-- Edit 3 --
I also asked tiredofit (the docker container owner) for help, he mentioned, the container is not ment for restarting, its ment for cold starts.
Any suggestion how to accomplish this in Unraid?
BackupPC - Nginx authentication - log.txt