Create custom domain to existing site error

My first erpnext domain is www.sitea.com.

Now I creat another domain www.siteb.com.

I used these commands from frappe_docker docs:

echo "ROUTER=siteb" > ~/gitops/siteb.env
echo "SITES=\`www.siteb.com\`" >> ~/gitops/siteb.env
echo "BASE_SITE=www.sitea.com" >> ~/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 http://www.siteb.com, it only returns “404 page not found”.

curl http://www.siteb.com
404 page not found

When I visit https://www.siteb.com, it pops up “connection not secure”.

curl https://www.siteb.com
curl: (60) SSL certificate problem: self-signed certificate
More details here: https://curl.se/docs/sslcerts.html

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 http://www.sitea.com or https://www.sitea.com 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.middlewares.siteb.headers.customrequestheaders.Host: www.sitea.com
traefik.http.routers.siteb-http.entrypoints: http
traefik.http.routers.siteb-https.entrypoints: https
traefik.http.routers.siteb-http.rule: Host(`www.siteb.com`)
traefik.http.routers.siteb-https.rule: Host(`www.siteb.com`)
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.

1 Like