Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

reverseproxy: do not disable keepalive if proxy protocol is used #7300

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

Open
WeidiDeng wants to merge 7 commits into master
base: master
Choose a base branch
Loading
from pp-w-keepalive

Conversation

Copy link
Member

@WeidiDeng WeidiDeng commented Oct 11, 2025

If proxy protocol is enabled, keepalive was disabled because there was no known way to differentiate requests to the same upstream from different clients.

But caddy actually updates the url in the requests to point to the upstream, this url is then used to dial to the upstream unless if a proxy is used for this request, in which case the proxy url is used for the dial.

We can update the url to add unique identifiers to create a mapping between the client address and the upstream address so that connections can be kept alive and requests from different clients to the same upstream won't interfere with each other.

Using the following caddyfile:

{
 debug
 skip_install_trust
 local_certs
 servers :9080 {
 listener_wrappers {
 proxy_protocol {
 allow 192.168.100.103/24
 }
 }
 }
}
localhost {
 reverse_proxy 192.168.100.103:9080 {
 header_up Host {upstream_hostport}
 transport http {
 proxy_protocol v2
 }
 }
}
http://192.168.100.103:9080 {
 respond "{http.request.remote.host}" 200
}

And curl command will output the same response;

$ curl -k https://localhost --interface 127.0.0.1
127.0.0.1
$ curl -k https://localhost --interface ::1
::1

Assistance Disclosure

No AI was used.

@francislavoie francislavoie changed the title (削除) reverse proxy: do not disable keepalive if proxy protocol is used (削除ここまで) (追記) reverseproxy: do not disable keepalive if proxy protocol is used (追記ここまで) Oct 16, 2025
@francislavoie francislavoie added this to the v2.11.0 milestone Oct 16, 2025
@francislavoie francislavoie added the feature ⚙️ New feature or request label Oct 16, 2025
Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! Nice little improvement to an edgecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@francislavoie francislavoie francislavoie approved these changes

Assignees

No one assigned

Labels

feature ⚙️ New feature or request

Projects

None yet

Milestone

v2.11.0

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /