Best way for simple proxy?

I have a simple set up. I have 1 public IP so I want Caddy to proxy domains to hosts on the local network.

I currently have this: {
} {

However, is there any way to make it simpler, such as combining the two (same domain but different ports)? I want Caddy to get SSL certificates for the domains. Are there other options I should consider for a basic proxy that simply redirects to another host like this?

After reading some docs and forum posts I’ve come to this:, {
reverse_proxy {
header_up Host {}
header_up X-Real-IP {}
header_up X-Forwarded-For {}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}

Can anymore be done for a simple proxy?

Yep! That’s how to do it!

You don’t need any of the header_up stuff though. Caddy already sets the For and Proto headers on its own automatically, and the other 3 are very rarely necessary.

Those header_up options are very commonly copy pasted from config to config by users who aren’t sure what those do without understanding why they need them.

Is my understanding correct that if I just set domains like above, then Caddy takes care of http and https (including certificate) by itself so I never have to specify ports basically?


Nice, thanks :slight_smile:

Is it possible to disable http2 for domain with Caddy v2?
“http2 false” as used in v1 doesn’t seem to work?

No. Why would you need that? If the client doesn’t support http2, it will fallback to http1.1.

Alright, then there’s no need to disable it :slight_smile:

It is possible, but this is decided at the TLS layer:

tls {
    alpn http1.1

Still… don’t do this unless it’s really necessary @Amplificator – Francis is right, HTTP/2 will only be used if the client supports it.

1 Like

Alright, I’ll keep it enabled :slight_smile:

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