Proxying to multiple backends depending on the hostname

1. Caddy version (caddy version):


2. How I run Caddy:

Docker file (see below)

a. System environment:

Ubuntu 20.04

b. Command:

docker-compose up

    on_demand_tls {
        ask      http://railsplatform:3000/caddy_domain
        interval 2m
        burst    5

https:// {
    tls {
    reverse_proxy railsplatform:3000

Ok so I have the above configuration so far, I haven’t actually run it on the server just yet as I am still setting this up.

So I want my Caddyfile to be able to server requests for the following:

  1. Marketing website: (or
  2. Customer domains which will create a DNS entry to point to:

So my Caddyfile will serve requests for the market website, which should proxy requests to railsmarketing:3001.

My customers will make DNS entries to point to, these domains will need to use the on-demand lookup to verify that this domain should fetch a SSL certificate for. Requests for these domains should be proxied to a different backed like railsplatform:3000

My marketing website will also need a SSL certificate for

What changes does my Caddyfile need, b/c currently it will proxy all requests to a single backend.


You can just add another site block for the specific sites you want to be handled specially:, {
	reverse_proxy railsmarketing:3001

Or if you want to redirect to you can do this: {
} {
	reverse_proxy railsmarketing:3001

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