Set up Caddyfile

Caddy is a lightweight utility to manage SSL. That includes auto renewing the cert, saving you a lot of upkeep time.

Caddyfile is the config adapter for Caddy. The structure is as follow.

portainer.saidhasyim.com {  
        reverse_proxy portainer:9000  
}

The first section is the incoming URL. If you don't specify the protocol, it accepts both http and https.

The reverse_proxy section is the destination service to be called when the incoming URL is fired. Note that the port number is not the published port number. It is the internal port used within the server.

Reload Caddy after updating it by running docker compose exec -w /etc/caddy caddy caddy reload and launch the URL.

It will take a a few minutes for the SSL cert to be generated and handshaked in the background, before you can launch the URL in https successfully.

Joining Services to An Existing Network

Caddy also helps you join an existing network from another container through just docker-compose.yml.

Insert a new section called networks in the file containing the existing network name. It is a requirement to mark it as external.

networks:
  windmill_default:
    external: true

Add the below section too and include the network name. Setting network_mode: bridge to each service in docker-compose.yml will stop compose from creating a new network, which is needed if you want to join an existing network.

network_mode: bridge
    networks:
      - windmill_default

That's it. Reload Caddy and the container should now be present in an existing network.