acme-companion
acme-companion copied to clipboard
Nginx Proxy container exit with code 1 when try to notify
Bug description
I followed the documentation to deploy my nginx proxy in a Rasberry Pi 4 (4GB) but I think the documentation is outdated. For example, here https://github.com/nginx-proxy/acme-companion/blob/main/docs/Docker-Compose.md the label is make reference to the old repository "com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen" I thouth. In the documentation without docker-compose there is the same issue https://github.com/nginx-proxy/acme-companion/blob/main/docs/Advanced-usage.md but in this I saw I can use the env NGINX_DOCKER_GEN_CONTAINER for the same propose, so I try it and my docker-gen works but now the nginx-proxy container falls with exit code 1 when try to notify.
dockergen.1 | 2022/04/12 17:18:52 Generated '/etc/nginx/conf.d/default.conf' from 11 containers
dockergen.1 | 2022/04/12 17:18:52 Running 'nginx -s reload'
dockergen.1 | 2022/04/12 17:18:52 Error running notify command: nginx -s reload, exit status 1
acme-companion image version
Info: running acme-companion version v2.2.1
nginx-proxy's Docker configuration
# https://github.com/nginx-proxy/acme-companion/blob/main/docs/Docker-Compose.md
version: "3.9"
services:
# https://github.com/nginx-proxy/acme-companion
nginx-proxy:
image: nginxproxy/nginx-proxy
container_name: nginx-proxy
ports:
- 80:80
- 443:443
volumes:
- ${NGINX_CONF}:/etc/nginx/conf.d
- ${NGINX_CERTS}:/etc/nginx/certs:ro
- ${NGINX_VHOST}:/etc/nginx/vhost.d
- ${NGINX_HTML}:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
network_mode: bridge
# https://github.com/nginx-proxy/docker-gen
nginx-proxy-gen:
image: nginxproxy/docker-gen
container_name: nginx-proxy-gen
command: -notify-sighup nginx-proxy -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
volumes_from:
- nginx-proxy
volumes:
- ${NGINX_TMLP}:/etc/docker-gen/templates/nginx.tmpl:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
network_mode: bridge
# https://github.com/nginx-proxy/acme-companion
nginx-proxy-acme:
image: nginxproxy/acme-companion
container_name: nginx-proxy-acme
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-proxy-gen
- DEFAULT_EMAIL=${NGINX_ACME_EMAIL}
volumes_from:
- nginx-proxy
volumes:
- ${NGINX_CERTS}:/etc/nginx/certs:rw
- ${NGINX_ACME}:/etc/acme.sh
- /var/run/docker.sock:/var/run/docker.sock:ro
network_mode: bridge
rendered nginx configuration
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
default $http_x_forwarded_proto;
'' $scheme;
}
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
default $http_x_forwarded_port;
'' $server_port;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
default upgrade;
'' close;
}
# Apply fix for very long server names
server_names_hash_bucket_size 128;
# Default dhparam
# Set appropriate X-Forwarded-Ssl header based on $proxy_x_forwarded_proto
map $proxy_x_forwarded_proto $proxy_x_forwarded_ssl {
default off;
https on;
}
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$upstream_addr"';
access_log off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'xxxx';
ssl_prefer_server_ciphers off;
error_log /dev/stderr;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
proxy_set_header X-Original-URI $request_uri;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
server {
server_name _; # This is just an invalid value which will never trigger on a real hostname.
server_tokens off;
listen 80;
access_log /var/log/nginx/access.log vhost;
return 503;
}
server {
server_name _; # This is just an invalid value which will never trigger on a real hostname.
server_tokens off;
listen 443 ssl http2;
access_log /var/log/nginx/access.log vhost;
return 503;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_certificate /etc/nginx/certs/default.crt;
ssl_certificate_key /etc/nginx/certs/default.key;
}
# xxx.duckdns.org
upstream xxx.duckdns.org {
# Cannot connect to network 'webserver_default' of this container
# Fallback entry
server 127.0.0.1 down;
}
server {
server_name xxx.duckdns.org;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
# Do not HTTPS redirect Let'sEncrypt ACME challenge
location ^~ /.well-known/acme-challenge/ {
auth_basic off;
auth_request off;
allow all;
root /usr/share/nginx/html;
try_files $uri =404;
break;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
server_name xxx.duckdns.org;
listen 443 ssl http2 ;
access_log /var/log/nginx/access.log vhost;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_certificate /etc/nginx/certs/xxx.duckdns.org.crt;
ssl_certificate_key /etc/nginx/certs/xxx.duckdns.org.key;
ssl_dhparam /etc/nginx/certs/xxx.duckdns.org.dhparam.pem;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/nginx/certs/xxx.duckdns.org.chain.pem;
add_header Strict-Transport-Security "max-age=31536000" always;
location / {
proxy_pass http://xxx.duckdns.org;
}
}
Containers logs
_nginx-proxy-acme_logs.txt _nginx-proxy-gen_logs.txt _nginx-proxy_logs.txt
Docker host
OS
Raspberry Pi OS Lite 64bits
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Docker version:
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:47:24 2022
OS/Arch: linux/arm64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.14
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 87a90dc
Built: Thu Mar 24 01:45:44 2022
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.5.11
GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0