简体   繁体   中英

Mail server docker with certbot

I pull https://github.com/tomav/docker-mailserver for setup a mail server. I would like add Let's encrypt support, so I pull too https://hub.docker.com/r/certbot/certbot/~/dockerfile/

I do a Docker compose file with this 2 container :

version: '2'
services:
 nginx:
image: pixelfordinner/nginx
container_name: pixelcloud-nginx_proxy-nginx
restart: always
ports:
  - "80:80"
  - "443:443"
volumes:
  - "./volumes/conf.d:/etc/nginx/conf.d:ro"
  - "./volumes/vhost.d:/etc/nginx/vhost.d:ro"
  - "./volumes/certs:/etc/nginx/certs:ro"
  - "/usr/share/nginx/html"
nginx-proxy:
 image: jwilder/docker-gen
 container_name: nginx-proxy
 depends_on:
  - nginx
 volumes_from:
  - nginx
 volumes:
  - "/var/run/docker.sock:/tmp/docker.sock:ro"
  - "./data/templates:/etc/docker-gen/templates:ro"
  - "./volumes/conf.d:/etc/nginx/conf.d:rw"
entrypoint: /usr/local/bin/docker-gen -notify-sighup pixelcloud-nginx_proxy-nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf

letsencrypt-nginx-proxy:
restart: always
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: ssl
depends_on:
  - nginx
  - nginx-proxy
volumes_from:
  - nginx
volumes:
  - "/var/run/docker.sock:/var/run/docker.sock:ro"
  - "./volumes/vhost.d:/etc/nginx/vhost.d:rw"
  - "./volumes/certs:/etc/nginx/certs:rw"
environment:
  - "NGINX_DOCKER_GEN_CONTAINER=nginx-proxy"
 mail:
image: tvial/docker-mailserver:2.1
hostname: mail
domainname: example.com
container_name: mail
ports:
- "25:25"
- "143:143"
- "587:587"
- "993:993"
volumes:
- maildata:/var/mail
- mailstate:/var/mail-state
- ./config/:/tmp/docker-mailserver/
- "$PWD/etc/:/etc/letsencrypt/"
- "$PWD/log/:/var/log/letsencrypt/"
environment:
- ENABLE_SPAMASSASSIN=1
- ENABLE_CLAMAV=1
- ENABLE_FAIL2BAN=1
- ENABLE_POSTGREY=1
- ONE_DIR=1
- DMS_DEBUG=0
- SSL_TYPE=letsencrypt
cap_add:
- NET_ADMIN
certbot:
image: certbot/certbot
container_name: certbot
command: certbot certonly --standalone -d mail.example.com
ports:
- "8083:80"
- "4432:443"
volumes:
  - /etc/letsencrypt:/etc/letsencrypt
  - /var/lib/letsencrypt:/var/lib/letsencrypt

But certbot does not create any certificate. There is a conflict between nginx and certbot containers with the 443 port.

If I use the 443 port for certbot, my domain is not reachable and so the certbot domain verification fail. If I use 443 for nginx, certbot is not working. I don't know what to do...

Let's encrypt (certbot) require existing tld which is accessable via port 80 to actually do something. You need to create some real domain like dev.existingdomain.com and use it.

https://typo3worx.eu/2016/11/lets-encrypt-on-localhost/

For local environment you mostly use self signed certs ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM