Nextcloud-AIO Docker container can't connect to domain behind Caddy

Partial success!

I installed a new image of Caddy with more modules, including Cloudflare DNS and DDNS support, from this repo. I then replicated the config described in this post.

Caddyfile:

{
        debug
 }

(cloudflare) {
        tls {
                dns cloudflare {env.CF_API_TOKEN}
        }
}

https://cloud.example.com:443 {
        import cloudflare
        reverse_proxy nextcloud-aio-apache:11000
}

Docker Compose file for Nextcloud-AIO:

services:
  nextcloud-aio-mastercontainer:
    image: nextcloud/all-in-one:latest
    init: true
    restart: always
    container_name: nextcloud-aio-mastercontainer
    volumes:
      - nextcloud_aio_mastercontainer:/mnt/docker-aio-config
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 5050:8080
    environment:
      # - APACHE_ADDITIONAL_NETWORK=caddy
      - APACHE_PORT=11000
      - APACHE_IP_BINDING=127.0.0.1
      - NEXTCLOUD_DATADIR=<directory>
    networks:
      - caddy
      
volumes:
  nextcloud_aio_mastercontainer:
    name: nextcloud_aio_mastercontainer

networks:
  caddy:
    external: true

Docker Compose file for Caddy:

services:
  caddy:
    image: serfriz/caddy-cloudflare-ddns-crowdsec-geoip-security-dockerproxy:2.9.1
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    environment:
      - CADDY_INGRESS_NETWORKS=caddy,nextcloud-aio
      - CADDY_DOCKER_CADDYFILE_PATH=/etc/caddy/Caddyfile # I think this is a path inside the container?
    networks:
      - caddy
      - nextcloud-aio
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./Caddyfile:/etc/caddy/Caddyfile
      #- ./site:/srv
      - caddy_data:/data
      - caddy_config:/config

networks:
  caddy:
    external: true
  nextcloud-aio:
    external: true

volumes:
  caddy_data:
  caddy_config:

With all this entered, I was able to pass Nextcloud-AIO’s domain check, and Nextcloud-AIO reported that it successfully began all its component containers.

However, at that point, I ran into a new error: I couldn’t log in with the auto-generated admin username and password. But I’ll create a new issue for that.