crtxdmp.

A collection of ideas, snippets and other things.


Automated https with nginx proxy in docker

File: docker-compose.yml
version: "2"
services:
  public_service:
    image: hello-world
    restart: unless-stopped
    environment:
      - VIRTUAL_HOST=iam.public.com

#region proxy and https
  proxy:
    image: jwilder/nginx-proxy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - dhparam:/etc/nginx/dhparam
      - certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    labels:
      - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy
    environment:
      - HSTS=off
      - VIRTUAL_PROTO=http

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    restart: unless-stopped
    depends_on:
      - proxy
    environment:
      - NGINX_PROXY_CONTAINER=proxy
      - [email protected]
    volumes_from:
      - proxy
    volumes:
      - certs:/etc/nginx/certs:rw
      - acme:/etc/acme.sh
      - /var/run/docker.sock:/var/run/docker.sock:ro
#endregion

volumes:
  conf:
  vhost:
  html:
  dhparam:
  certs:
  acme:

, — May 10, 2021