Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support known tls placeholders replacing even for non tls request #5154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nikolaevn
Copy link

This Caddyfile produce incorrect upstreams headers (placeholders not replaced at all)

http://localhost:1337 {
	reverse_proxy / {
		to http://localhost:1339
		header_up XXX1 {http.request.tls.client.certificate_der_base64}
		header_up XXX2 {http.request.tls.client.san.uris.0}
	}
}

Without this PR upstream gets following:

GET / HTTP/1.1
Host: localhost:1337
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: localhost:1337
X-Forwarded-Proto: http
Xxx1: {http.request.tls.client.certificate_der_base64}
Xxx2: {http.request.tls.client.san.uris.0}

with PR:

GET / HTTP/1.1
Host: localhost:1337
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: localhost:1337
X-Forwarded-Proto: http
Xxx1: 
Xxx2: 

@CLAassistant
Copy link

CLAassistant commented Oct 18, 2022

CLA assistant check
All committers have signed the CLA.

@caddyserver caddyserver deleted a comment from yanshin1499 Oct 20, 2022
@mholt
Copy link
Member

mholt commented Oct 20, 2022

Thanks for the PR!

This looks good, but before merging I just want to double check if this is the way we want it to work.

We could alternatively simply change repl.ReplaceKnown() (in headers.go) to repl.ReplaceAll() -- assuming that header fields don't otherwise have {...} in them. That's why I used ReplaceKnown up to now.

So, this is probably the safest way to go but it is a bit repetitive (which is fine, as I don't know another way to do it). Any thoughts? (Don't change your patch though.)

@francislavoie
Copy link
Member

I think that changes in #5275 will affect what needs to be done here, once that one is completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants