Closed roger6106 closed 6 months ago
Upstream address must not contain a scheme when using placeholders, it needs to be only the host & port. See https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#upstream-addresses
If the address is not a URL (i.e. does not have a scheme), then placeholders can be used, but this makes the upstream dynamically static, meaning that potentially many different backends act as a single, static upstream in terms of health checks and load balancing. We recommend using a dynamic upstreams module instead, if possible. When using placeholders, a port must be included (either by the placeholder replacement, or as a static suffix to the address).
If you want to configure HTTPS, then add this to your proxy config:
transport http {
tls
}
And you may also need header_up Host {upstream_hostport}
as per https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#https
For next time, please ask your usage questions on the Caddy community forums. We prefer to keep the GitHub issue board for bugs and feature requests. Don't forget to fill out the thread template so we can help you!
Thank you! I was sure there had to be a way. The error showing a lookup of lookup /www.yahoo.com
was what was throwing me off, especially since I was able to use a schema when I inserted it directly.
When using a placeholder as an address for reverse_proxy, it appears to prefix the domain name with a
/
.This can be replicated with this simple caddyfile:
The console error shows:
As for why I can't use an alternative approach, the goal is to do some dev work that needs to reverse_proxy paths from various servers. Here's a simplified version of what I am trying to accomplish (using public sites for simplicity):
Caddy --version is
v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A