Need help setting up discourse using Caddy as rproxy

If i’m not posting this in the right section, i’m sorry.

I’m using Oracle Free tier as my server, and i have a Ubuntu installation with a couple of docker containers running.
I’m using Caddy, also running in docker, as rproxy for all my containers.

Now i need to setup Discourse as the last piece of the puzzle, but i’m not sure how to proceed.
I have testet and installed Discourse with a standard docker installation on my other testserver, but that’s the whole package, and if i need to use caddy as rproxy, i need to disable some of the features i guess?

If anyone could point me in the right direction, i would much appriceate it.

This might be helpful:

1 Like

I think that got me on the right track. I’m not sure i’m pointing to the right path though.

in my app.yml I have set my volumes here:
And i can build my Discourse without problems.

volumes:
  - volume:
      host: /opt/docker/docker_configs/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /opt/docker/docker_configs/discourse/shared/standalone/log/var-log
      guest: /var/log

And reading that forumthread, i tried a couple of things with my Caddyfile.

forum.mydomain.com {
  reverse_proxy unix//opt/docker/docker_configs/discourse/shared/standalone/nginx.http.sock
  import cloudflare
}
forum.mydomain.com {
  reverse_proxy /opt/docker/docker_configs/discourse/shared/standalone/nginx.http.sock
  import cloudflare
}

Neither of them work, but i’m really not sure i’m doing it right though xD

How are you starting caddy?

This line from the original topic needs to be adjusted for your directory for this to work. Unless the correct directory is mounted in caddy container, it can not see the socket created by discourse.

Arh, you mean that i need to mount the discourse sock to caddy? that makes sense!

I tried something else last night however.
When discourse is started, it is running in a docker bridge network. If i just add the docker-default network that all my other containers, including Caddy, is in, then i can simply add it to caddy like i do with all my other containers.

forum.mydomain.com {
  reverse_proxy app:80
  import cloudflare
}

I couldn’t figure out where the docker network is defined in all those yml files though. If i could change it from the bridge to run in docker default, all is fixed for me.

This might be helpful:

While it is for Nginx Proxy Manager, It describes the process of bringing containers under default bridge.

1 Like

Yes! it works!

I had to change a couple of things, but it is almost as the first thread you linked.

In Caddyfile i had to write it like this
Which is a bit different than written in the thread.

forum.mydomain.com {
  reverse_proxy unix//sock/nginx.http.sock
  import cloudflare
}

and I’ve added the volume, which of course makes sense when i now think of it.
I’m using docker-compose.

  caddy:
    container_name: Caddy
    build:
      dockerfile: ./caddy-config/Dockerfile
      context: .
    labels:
      com.centurylinklabs.watchtower.enable: "false"
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./docker_configs/caddy/data:/data
      - ./docker_configs/caddy/Caddyfile:/etc/caddy/Caddyfile
      - ./docker_configs/caddy/srv:/srv
      - /var/discourse/shared/standalone:/sock
    restart: always

Thanks alot for the help!

1 Like

That is probably due to upstream changes in Caddy itself. The image linked in the topic still works with the provided configuration afaik.

1 Like