Understanding How Caddy Works with Multiple Subdomains as a Reverse Proxy

Hi Everyone!

I am currently running Caddy through the Rocket.Chat Snap and I fail to understand how to get Caddy to handle multiple subdomains.

Currently, I have a chat subdomain for my Rocket.Chat instance. My Caddyfile looks like this:

https://chat.domainname.com
proxy / localhost:3000 {
websocket
transparent
}

Now, from what I understand, to add another domain to this, all I have to do is just add this block again with a modified subdomain and port number. Is this correct? What I have tried is this:

https://bitwarden.domainname.com
proxy / localhost:8181{
websocket
transparent
}

I am trying to get Bitwarden to be SSL verified under this one caddy install as well as my Rocket.Chat instance. When I add the block above to my Caddyfile underneath the Rocket.Chat one, the Rocket.Chat subdomain doesn’t load at all. I was wondering why this would be the case.

I have tried asking on the Rocket.Chat forums, however, there hasn’t been any response, so, I figured I would ask here in case someone had this issue in the past.

Thank you for your time.

To have multiple sites, you need to use curly brackets around the config for each site:

See here for an explanation: https://caddyserver.com/v1/docs/caddyfile#structure

https://chat.domainname.com {
    proxy / localhost:3000 {
        websocket
        transparent
    }
}

https://bitwarden.domainname.com {
    proxy / localhost:8181 {
        websocket
        transparent
    }
}
2 Likes

Thank you so much for the help! This helped me get past the hurdle I was encountering. I’m not sure why I didn’t check my brackets in the Caddyfile…

Thank you so much!!

1 Like

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