How can I reverse_proxy requests of multi domain to upstream?

1. The problem I’m having:

  • I have a node js server which handles many web apps for many customers’ domain names. and the new domain names are keeping added.
  • How can I use the caddy to reverse_proxy all requests to my node js upstream with the SSL setup ?

my current Caddyfile which is working:

www.abc.net, www.def.com {
	reverse_proxy localhost:3020
}

What I intend is:

* {
     reverse_proxy localhost:3020
}

This way I don’t need to update the caddyfile when the new domains added. The problem is this is not working.

Please advise.
Thanks.

2. Error messages and/or full log output:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

3. Caddy version:

4. How I installed and ran Caddy:

a. System environment:

b. Command:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

5. Links to relevant resources:

You’re looking for On-Demand TLS: Automatic HTTPS — Caddy Documentation

Thanks @francislavoie

I follow what you mentioned and solve the issue.

The following is my caddyfile

{
        on_demand_tls {
                ask http://localhost:3010/domain/exists
        }
}

*.au.abc.net {
	tls {
		dns vultr HXQT77XQ76O5FKR2KSGPR22222MGDBHOA
	}

	@admin host admin.au.abc.net
	handle @admin {
		rewrite /chat /chat/
		handle_path /chat/* {
			rewrite * /socket.io{chat}
			reverse_proxy localhost:3010
		}

		reverse_proxy localhost:3010
	}

	handle {
		reverse_proxy localhost:3020
	}
}

:443 {
	tls {
                on_demand
        }
	reverse_proxy localhost:3020
}

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