Nginx container permission problem with custom UID/GID
I run Bitwarden with a custom user (set in bwdata/env/uid.env). The nginx container creates the "/var/run/nginx.pid" file with the correct owner (as in uid.env), but the "/var/run" folder belongs to root so when the nginx process tries to delete the nginx.pid file the permission is denied and nginx stops.
A way to fix this would be to add to entrypoint.sh :
...
touch /var/run/nginx.pid
chown -R $USERNAME:$GROUPNAME /var/run/nginx.pid
chown root:$GROUPNAME /var/run
chmod 775 /var/run
...
This allows to keep the root ownership, while allowing nginx to delete the file
I would assume that if /var/run/nginx.pid has the correct permissions it should still be able to be deleted even if the directory containing it does not. Am I mistaken?
As seen in here, you need to be able to delete the file from the directory files list
Thanks. I am not sure allowing our application group write access to /var/run is a good idea though...? https://serverfault.com/a/159349/405627
You're right. I made a pull request moving nginx.pid to /var/run/nginx owned by the application user