Skip to content

SSL HTTPS Configuration

Cyril Rohr edited this page Feb 10, 2021 · 10 revisions

Example using the Caddy reverse-proxy with automatic Let's Encrypt certificate generation:

version: '3.7'
networks:
  frontend:
    attachable: true
  backend:
    attachable: true

services:
  proxy:
    image: caddy:2
    restart: unless-stopped
    command: "caddy reverse-proxy --from '${PULLPREVIEW_URL}' --to web:3000"
    networks:
      - frontend
      - backend
    depends_on:
      - web
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "caddy_data:/data"

  web:
    build: .
    command: "start/my/app --port 3000 --bind 0.0.0.0"
    ports:
      - "3000"
    networks:
      - backend

The PULLPREVIEW_URL is one of the environment variables automatically available to your Docker Compose files, and contains the full URL to your ephemeral server.

Clone this wiki locally