Create custom domain to existing site error

My first erpnext domain is

Now I creat another domain

I used these commands from frappe_docker docs:

echo "ROUTER=siteb" > ~/gitops/siteb.env
echo "SITES=\`\`" >> ~/gitops/siteb.env
echo "" >> ~/gitops/siteb.env
echo "BENCH_NETWORK=sitea" >> ~/gitops/siteb.env

docker compose --project-name siteb \
  --env-file ~/gitops/siteb.env \
  -f overrides/compose.custom-domain.yaml \
  -f overrides/compose.custom-domain-ssl.yaml config > ~/gitops/siteb.yaml

docker compose --project-name siteb -f ~/gitops/siteb.yaml up -d

I found caddy:2 container was created successfully.

But when I visit, it only returns “404 page not found”.

404 page not found

When I visit, it pops up “connection not secure”.

curl: (60) SSL certificate problem: self-signed certificate
More details here:

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

My visit to or is ok.

So, what’s wrong?

I think there are some mistake while composing compose.custom-domain.yaml and compose.custom-domain-ssl.yaml into the file siteb.yaml.

In siteb.yaml, it combined http/https entrypoints and a certresolver label at same time.

    traefik.http.routers.siteb.entrypoints: http,https
    traefik.http.routers.siteb.tls.certresolver: le

In sitea.yaml, it is like:

    traefik.http.routers.sitea-http.entrypoints: http
    traefik.http.routers.sitea-https.entrypoints: https
    traefik.http.routers.sitea-https.tls.certresolver: le

I’m not sure.

I have just confirmed it.
We should not combined http/https entrypoints and a certresolver label at same time.
I changed siteb.yaml to:

traefik.http.routers.siteb-http.middlewares: siteb
traefik.http.routers.siteb-https.middlewares: siteb
traefik.http.routers.siteb-http.entrypoints: http
traefik.http.routers.siteb-https.entrypoints: https
traefik.http.routers.siteb-http.rule: Host(``)
traefik.http.routers.siteb-https.rule: Host(``)
traefik.http.routers.siteb-http.service: siteb
traefik.http.routers.siteb-https.service: siteb
traefik.http.routers.siteb-https.tls.certresolver: le

Now custom domain works.