Use Caddy instead of NGNIX as your reverse proxy

For reference, these are the current steps for a non-dockerized setup using Caddy as reverse proxy:

1) Adjust the Discourse config file

  • Comment out certificates
    templates:
    #  - "templates/web.ssl.template.yml"
    #  - "templates/web.letsencrypt.ssl.template.yml"
    
  • Change port mapping and disable 443 mapping
    expose:
    - "8080:80"   # http
    # - "443:443" # https
    
  • Force HTTPS for serving static files
    env: 
    DISCOURSE_FORCE_HTTPS: true
    

2) Rebuild Discourse

./launcher rebuild app

3) Setup Caddy

  • Install Caddy, just using the official defaults: Install — Caddy Documentation

  • Adjust /etc/caddy/Caddyfile

    forum.example.com {
          reverse_proxy localhost:8080
    }
    

    If you have multisite, you can just list your domains:

    forum.example.com, forum2.example.com, forum3.example.com {
          reverse_proxy localhost:8080
    }
    

    You can also run systemctl status caddy to verify the default config file location.

4) Run Caddy

systemctl start caddy

Reload configuration after changes:

cd /etc/caddy
caddy reload
2 Likes