1. The problem I’m having:
I’m hoping to be able to change the request headers before reaching the authentication handler.
I’m using the caddy-tailscale plugin as the authentication handler. The caddy-tailscale plugin is expecting a Remote-Addr header. I’m also using Flyio which passes the client ip in a Fly-Client-Ip header. I need to modify the Remote-Addr header to have the value of the Fly-Client-Ip.
When I add the headers handler portion I start getting Could not proxy HTTP request. Retrying in 24 ms (attempt 1)
which I think means Caddy isn’t getting any response. Without the headers handler Caddy accepts requests but is using the wrong Remote-Addr value with caddy-tailscale plugin.
Is there something I’m doing wrong in Caddy or is this on the caddy-tailscale plugin side of things? If I can just make sure I’m doing things correctly in Caddy it will help me know where I should be debugging
2. Error messages and/or full log output:
Could not proxy HTTP request. Retrying in 24 ms (attempt 1)
3. Caddy version:
2.6.4
4. How I installed and ran Caddy:
a. System environment:
Dockerfile → Flyio VM
b. Command:
caddy run --config /config/caddy/caddy.json
c. Service/unit/compose file:
d. My complete Caddy config:
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":8080"
],
"routes": [
{
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "authentication",
"providers": {
"tailscale": {}
}
},
{
"handler": "headers",
"request": {
"set": {
"Remote-Addr": [
"{http.request.header.Fly-Client-Ip}"
]
}
}
},
{
"handler": "headers",
"request": {
"set": {
"Remote-Port": [
"{http.request.header.Fly-Forwarded-Port}"
]
}
}
}
]
},
{
"handle": [
{
"handler": "static_response",
"status_code": 200
}
],
"match": [
{
"host": [
"my-api.com"
]
}
]
}
]
}
],
"terminal": true
}
]
}
}
}
}
}