Inaccessible behind Traefik Proxy

AI-generated summary

tgrosinger encountered an issue running Discourse behind Traefik Proxy, where accessing the domain via Traefik resulted in a 504 timeout, despite the service responding correctly when curling the container’s internal IP. Traefik reported the service as available, and TLS certificates were correctly presented, but requests from the domain never reached Discourse’s nginx logs. After reviewing configuration and comparing with other working services, tgrosinger resolved the problem by ensuring Discourse and Traefik were on the same Docker network — the mismatched networks had prevented Traefik from routing requests properly to the Discourse container. The Discourse config included Traefik labels for routing, TLS, and load balancing, but network isolation was the root cause. This fix restored connectivity through Traefik without requiring changes to the Traefik or Discourse config files.

I’ve read through a bunch of posts about running Discourse behind a Traefik proxy, but unfortunately I seem to still be missing something.

From the host if I curl the internal IP of the container I can see the Discourse setup wizard html returned and Traefik reports that the service is available:

However when I attempt to connect to the domain that goes through Traefik I can see the expected https certificate but then get a 504 after several seconds.

Here’s my Discourse config:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"

expose:
  #- "80:80"   # http
  #- "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8

  DISCOURSE_HOSTNAME: 'redacted'
  DISCOURSE_DEVELOPER_EMAILS: 'redacted'

  DISCOURSE_SMTP_ADDRESS: smtp.postmarkapp.com
  DISCOURSE_SMTP_USER_NAME: redacted
  DISCOURSE_SMTP_PASSWORD: redacted
  DISCOURSE_NOTIFICATION_EMAIL: noreply@redacted

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /opt/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /opt/discourse/shared/standalone/log/var-log
      guest: /var/log

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

docker_args:
  - "-l traefik.enable=true"
  - "-l traefik.http.routers.discourse.tls=true"
  - "-l traefik.http.routers.discourse.rule=Host(`redacted`)"
  - "-l traefik.http.routers.discourse.entrypoints=websecure"
  - "-l traefik.http.routers.discourse.tls.certresolver=ledns"
  - "-l traefik.http.services.discourse.loadbalancer.server.port=80"
  - "-l traefik.http.services.discourse.loadbalancer.server.scheme=http"

run:
  - exec: echo "Beginning of custom commands"
  - exec: echo "End of custom commands"

I have many other services in the same Traefik instance configured similarly on different hosts and they are all working.

In the Discourse nginx access logs I can see the request when I curl the local IP, but not when I curl the domain.

Any suggestions on what is missing? It seems like it’s getting lost somewhere between Traefik and nginx.

I found the issue. Traefik and Discourse were on different docker networks. Adding a docker flag to put it on the same network solved the issue.