mkrensing
(mkrensing)
December 30, 2019, 4:28pm
1
1. My Caddy version (caddy version
):
v2.0.0-beta9
2. How I run Caddy:
./caddy run -config Caddyfile
https://svn.example.com {
#log /opt/caddy/logs/log.log
#errors /opt/caddy/logs/errors.log
reverse_proxy / 192.168.1.100:8088 {
header_up SuperstarHeader SuperstarValue
header_up OriginalDestination {http.request.header.Destination}
header_up OriginalConnection {http.request.header.Connection}
header_up +Destination "https://svn.example.com(.*)" "http://192.168.1.100:8088/$1"
}
tls /opt/caddy/certs/svn.example.com.crt /opt/caddy/certs/svn.example.com.key
}
3. The problem I’m having:
I upgraded my caddy version to v2 for testing http 502 - caddy proxies to svn server · Issue #2018 · caddyserver/caddy · GitHub
The header_up does not work with {http.request.header.*} placeholders.
The headers are present but empty.
Whats the v2 statement for
header_upstream Destination "https://svn.example.com(.*)" "http://192.168.1.100:8088/$1"
to set the Destination header correctly?
4. Error messages and/or full log output:
The header SuperstarHeader is present with correct value
The headers OriginalDestination and OriginalConnection are present but empty.
The Destination header is not present
5. What I already tried:
crying in bed alone
6. Links to relevant resources:
http 502 - caddy proxies to svn server · Issue #2018 · caddyserver/caddy · GitHub
2 Likes
matt
(Matt Holt)
December 30, 2019, 6:37pm
2
Thanks for trying v2!
I just tried with your config, and it works fine. Obviously, the client needs to send those headers in the request or it will be empty. When they are set, your config sets them properly.
mkrensing:
Whats the v2 statement for
header_upstream Destination "https://svn.example.com(.*)" "http://192.168.1.100:8088/$1"
to set the Destination header correctly?
(Is that even a valid v1 statement?)
It sounds like you want to append the request path to the Destination header, so:
header_up Destination "http://192.168.1.100:8088{path}"
Should do the trick.
PS. Use v2 beta 11, which was released last week.
It is, yes:
caddyserver:master
← comp500:rewriteheader
opened 01:04AM - 28 Apr 18 UTC
<!--
Thank you for contributing to Caddy! Please fill this out to help us make … the most of your pull request.
-->
### 1. What does this change do, exactly?
Adds an extra parameter to header_upstream and header_downstream that allows regex-based replacement of headers. They are in the format `header_upstream [header] [regex] [replacement]`
This allows unwanted values from the server and client (e.g. redirects, cookies) to be modified by Caddy. This therefore allows search (and mobile) to be fixed on [wikipedia.matt.life](https://wikipedia.matt.life), and [wikimirror](https://github.com/CristianCantoro/wikimirror).
### 2. Please link to the relevant issues.
#442 - An existing (but not merged) implementation of Location rewriting
#606 - Nginx proxy_redirect feature request
This change may be obsoleted by #1639, the proxy middleware rewrite.
### 3. Which documentation changes (if any) need to be made because of this PR?
Add the extra parameter to header_upstream and header_downstream, and describe it. Give examples of it being used to change the Location header, possibly referencing proxy_redirect.
### 4. Checklist
- [x] I have written tests and verified that they fail without my change
- [x] I have squashed any insignificant commits
- [x] This change has comments for package types, values, functions, and non-obvious lines of code
- [x] I am willing to help maintain this change if there are issues with it later
(Seems it shall remain forever undocumented, heh)
system
(system)
Closed
April 1, 2020, 4:03am
4
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.