JonasAlfredsson/docker-nginx-certbot

Getting errors using custom config

samchouse opened this issue · 2 comments

nginx.conf

# Generated by nginxconfig.io
# See nginxconfig.txt for the configuration share link

user nginx;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 65535;

# Load modules
include /etc/nginx/modules-enabled/*.conf;

events {
	multi_accept on;
	worker_connections 65535;
}

http {
	charset utf-8;
	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	server_tokens off;
	log_not_found off;
	types_hash_max_size 2048;
	types_hash_bucket_size 64;
	client_max_body_size 16M;

	# MIME
	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	# Logging
	log_format main '$remote_addr - $remote_user [$time_local] "$request" '
	'$status $body_bytes_sent "$http_referer" '
	'"$http_user_agent" "$http_x_forwarded_for"';
	access_log /var/log/nginx/access.log main;
	error_log /var/log/nginx/error.log notice;

	# SSL
	ssl_session_timeout 1d;
	ssl_session_cache shared:SSL:10m;
	ssl_session_tickets off;

	# Diffie-Hellman parameter for DHE ciphersuites
	ssl_dhparam /etc/letsencrypt/dhparams/dhparam.pem;

	# Mozilla Intermediate configuration
	ssl_protocols TLSv1.2 TLSv1.3;
	ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;

	# OCSP Stapling
	ssl_stapling on;
	ssl_stapling_verify on;
	resolver 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
	resolver_timeout 2s;

	# Connection header for WebSocket reverse proxy
	map $http_upgrade $connection_upgrade {
		default upgrade;
		"" close;
	}

	map $remote_addr $proxy_forwarded_elem {

		# IPv4 addresses can be sent as-is
		~^[0-9.]+$ "for=$remote_addr";

		# IPv6 addresses need to be bracketed and quoted
		~^[0-9A-Fa-f:.]+$ "for=\"[$remote_addr]\"";

		# Unix domain socket names cannot be represented in RFC 7239 syntax
		default "for=unknown";
	}

	map $http_forwarded $proxy_add_forwarded {

		# If the incoming Forwarded header is syntactically valid, append to it
		"~^(,[ \\t]*)*([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?(;([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?)*([ \\t]*,([ \\t]*([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?(;([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?)*)?)*$" "$http_forwarded, $proxy_forwarded_elem";

		# Otherwise, replace it
		default "$proxy_forwarded_elem";
	}

	# Load configs
	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}

docker-compose

nginx:
    image: jonasal/nginx-certbot:latest
    restart: unless-stopped
    profiles:
      - deploy
    env_file:
      - deploy.env
    ports:
      - 80:80
      - 443:443
    volumes:
      - letsencrypt:/etc/letsencrypt
      - ./data/nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./data/nginx/sites-available:/etc/nginx/sites-available
      - ./data/nginx/nginxconfig.io:/etc/nginx/nginxconfig.io
      - ./data/letsencrypt/cloudflare.ini:/etc/letsencrypt/cloudflare.ini

image

It never generates certificate. What's going wrong?

Hi Xenfo,

Have you read this and this?

Because you overwrite the main nginx.conf (which is not recommended), and you don't specify any ssl_certificate_key paths.

Thanks, that fixed it.