1. The problem I’m having:
How to get the value of a key that may appear in header or url
I have an uuid parameter in the url or in the Referer part of the header, which may only appear in one of them. And I want to send it to another server to authorize using reverse_proxy
The uuid parameter may appear in the url:
https://domain/?uuid=val_a
or in header:
Referer: https://domain/?uuid=val_a
3. Caddy version:
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
4. How I installed and ran Caddy:
d. My complete Caddy config:
{
debug
order respond after reverse_proxy
}
domain.com {
root /path/path
encode zstd gzip
@uuid expression header_regexp('uuid', 'Referer', 'uuid=([0-9a-zA-Z_]+)') || {query}.matches(r'([0-9a-zA-Z_]+)')
reverse_proxy @uuid 127.0.0.1:6111{
method GET
rewrite /verify?uuid={re.1} ### How to get the correct value.
### {re.1} not woring when uuid is only in url
header_up X-Forwarded-Method {method}
header_up X-Forwarded-Uri {uri}
@good status 2xx
handle_response @good {
file_server
}
}
respond 404
}