Multiple Domains - multiple Caddys

1. The problem I’m having:

I need a proxy that forwards every https request from two domains (s1.mydomain.de and s2.mydomain.de) to two separate caddy server. Each Caddy server must handle CERT generation and subdomains.

I don’t know how to configure that.

Example:

caddy-server-1 should handle *.s1.mydomain.de
caddy-server-2 should handle *.s2.mydomain.de

Caddyfile on caddy-server-1:

{
    email my.email@gmail.com
    acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}

# -- NOT WORKING --
#s2.mydomain.de {
#  reverse_proxy /* https://192.168.178.251
#}

traccar.s1.mydomain.de {
    reverse_proxy http://traccar:8082
}

nextcloud.s1.mydomain.de {
    reverse_proxy http://nextcloud:8083
}

Caddyfile on caddy-server-2:

{
    email my.email@gmail.com
    acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}

test.s2.mydomain.de {
    reverse_proxy http://test-docker-container:8001
}

Everything on s1.mydomain.de is working well. Thanks to caddy!

External DNS configuration for all subdomains are also fine:

s1.mydomain.de, *.s1.mydomain.de, s2.mydomain.de, *.s2.mydomain.de are pointing to the correct target server.

Requirements:

  • caddy-server-2 musst generate certificates for each subdomain (e.g. test.s2.mydomain.de)

4. How I installed and ran Caddy:

Everything is dockerized.

Thanks!

We can’t answer that without the full details of the template.

You might want to have a look at the layer4 module, GitHub - mholt/caddy-l4: Layer 4 (TCP/UDP) app for Caddy.

Citing from it’s readme: “If the HTTP Host is example.com or the TLS ServerName is example.com, then proxy to 192.168.0.4.”

Though I’m not quite sure if that really works for you since you still need to access information that caddy-1 cant have in your current setup.

I’ve update my post

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.