macbre / docker-nginx-http3

Stable and up-to-date root-less nginx with quic + http/3, google brotli compression, njs, GeoIP2, and Grade A+ SSL config
https://hub.docker.com/r/macbre/nginx-http3
172 stars 54 forks source link

Added uid and gid ARG for nginx user #123

Closed victor-sm closed 11 months ago

victor-sm commented 11 months ago

Added ARG variables to easily set a different uid, gid for the nginx user.

Example usage with a docker compose file:

services:
  nginx:
    build: 
      context: ./nginx/
      args:
        NGINX_USER_UID: 50010
        NGINX_GROUP_GID: 50010
    restart: always
    ports:
      - 80:8080
      - 443:8443
      - 443:8443/udp
     [...]

Since this build is running nginx as a non-root user, I had problems accessing certs created by certbot (which runs as root). By setting a custom uid/gid at build corresponding to a user on the host system, I could then give nginx permission using Access Control list (ACL) to the cert volume, thus allowing it to read the files.

Based on this guide.

victor-sm commented 11 months ago

Would also solve:

99 Can I set uid and gid for the internal user?

macbre commented 11 months ago

@victor-sm - welcome and thanks for the PR!