Caddy configuration reddit / selfhosted ---------------------------------------------------------------------- Basic_Promise6240 · 2023-12-20 08:26 Hello ! Recently, I decided to stop using all cloud services that I use for my projets and my self (Vercel, Google Drive, Neon...) to selfhost them on a VPS. I want to setup next-cloud and all my other apps using Caddy as reverse proxy. Every app are containerized including caddy. I did a lot of research and tried a lot of configs before posting here. ​ apps/ ├─ caddy/ │ ├─ compose.yml │ ├─ Caddyfile ├─ next-cloud/ │ ├─ compose.yml │ ├─ .env ├─ other-app/ │ ├─ compose.yml │ ├─ .env ├─ .../ I setup a network with : $ docker network create -d bridge caddy_network Here is my `apps/caddy/compose.yml` version: "3.9" services: caddy: image: caddy:latest container_name: caddy restart: unless-stopped ports: - "80:80" - "443:443" - "443:443/udp" volumes: - ./Caddyfile:/etc/caddy/Caddyfile - ./site:/srv - caddy_data:/data - caddy_config:/config networks: - caddy_network networks: caddy_network: external: true volumes: caddy_data: caddy_config: And my `app/caddy/Caddyfile` https://subdomain.domain.tld:443 { reverse_proxy next-cloud:11000 } Here is my `apps/next-cloud/compose.yml` version: "3.9" services: nextcloud-aio-mastercontainer: container_name: nextcloud-aio-mastercontainer image: nextcloud/all-in-one:latest restart: unless-stopped volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - nextcloud_aio_mastercontainer:/mnt/docker-aio-config ports: - 8080:8080 environment: APACHE_PORT: 11000 networks: - caddy_network networks: caddy_network: external: true volumes: nextcloud_aio_mastercontainer: name: nextcloud_aio_mastercontainer The problem I have today is that when I go to `my-ip:8080` , I have the AIO next-cloud setup interface but when I try to setup my domain it says : Domain does not point to this server or the reverse proxy is not configured correctly. See the mastercontainer logs for more details. ('sudo docker logs -f nextcloud-aio-mastercontainer') And in the logs I get : nextcloud-aio-mastercontainer | NOTICE: PHP message: Expected was: 4e5161cc64a4ebe1775bbf5533468a1c35830296de44b55c nextcloud-aio-mastercontainer | NOTICE: PHP message: The error message was: And in my caddy container I got this logs: caddy | {"level":"error","ts":1703060420.8861177,"logger":"http.l og.error","msg":"dial tcp: lookup next-cloud on 127.0.0.11:53: server misbehaving","request":{"remote_ip":"192.168.224.1","remote_port":"357 48","client_ip":"192.168.224.1","proto":"HTTP/2.0","method":"GET","hos t":"subdomain.domain.tld","uri":"/","headers":{"Accept":["*/*"]},"tls" :{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","serv er_name":"cloud.emilien.io"}},"duration":0.00126612,"status":502,"err_ id":"b5znyhkim","err_trace":"reverseproxy.statusError (reverseproxy.go:1267)"} It looks like caddy received the request but not succeed to forward. Have you already setup a similar configuration on your vps? And if yes how you did you achieve to make everyone works together. In my research I found this caddy docker image that use docker labels to setup the config. But first I want to suceed to make it works with the official image. [https://github.com/lucaslorentz/caddy-docker-proxy?tab=readme-ov- file#with-docker-compose-file](https://github.com/lucaslorentz/caddy- docker-proxy?tab=readme-ov-file#with-docker-compose-file) Thank you very much for any help Emilien ---------------------------------------------------------------------- Sugardaddy_satan · 2023-12-20 08:50 next cloud is running on 8080 but you are pointing reverse proxy to apache 11000 ---------------------------------------------------------------------- Sugardaddy_satan · 2023-12-20 08:53 reverse_proxy aio-master-container:8080 ---------------------------------------------------------------------- Basic_Promise6240 · 2023-12-20 09:52 Thank you I will try this today. I think I came up with too much reflection that I didn't saw this obvious mistake. Thank you ---------------------------------------------------------------------- szaimen · 2023-12-20 11:24 Hi, can you follow https://github.com/nextcloud/all-in- one/blob/main/reverse-proxy.md#6-how-to-debug-things? ---------------------------------------------------------------------- kasalacto · 2023-12-20 11:45 I think the port is correct but the hostname next-cloud is not, that's why there is a lookup error in caddy logs, it cannot find an IP in the caddy-network device with that name. nextcloud master container should spawn a separate container for Apache service that uses defined port 11000. Then caddy should be configured to use the hostname or IP address of this Apache service container. ---------------------------------------------------------------------- watchdog_timer · 2023-12-20 13:57 I think that should be `reverse_proxy nextcloud-aio- mastercontainer:8080`, shouldn't it? ---------------------------------------------------------------------- boomertsfx · 2023-12-20 21:28 would use Traefik...it's way easier. But it looks like you're using the wrong hostname for your proxy to connect to... Use the service name and you'll be good ---------------------------------------------------------------------- -eschguy- · 2023-12-20 23:00 I have my structure setup like yours, and I don't bother defining a network, and just point my Caddyfile entries to the VM IP:port as necessary. So with the docker containers, I just have Caddyfile: service.$domain { tls internal import headers encode gzip zstd reverse_proxy $DockerLocalIP:servicePort } service2.$DOMAIN { tls internal import headers encode gzip zstd reverse_proxy $DockerLocalIP:service2Port } and so on. In this cast, $DockerLocalIP is the same across all entries, and the *Port is whatever is exposed in the service's compose file. ---------------------------------------------------------------------- Basic_Promise6240 · 2023-12-21 09:51 Thank all of you for your answers. I think that I definitely to take a small course on docker to manage my vps properly. I end up with going back to the traefik config I used before. And I will try to setup next-cloud with this. Thank you!