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

Proxy protocol v2, as declared in reverse_proxy / transport http, fails due to unitialized command byte #6300

Closed
eulores opened this issue May 5, 2024 · 0 comments · Fixed by #6301
Assignees
Labels
bug 🐞 Something isn't working good first issue 🐤 Good for newcomers
Milestone

Comments

@eulores
Copy link

eulores commented May 5, 2024

Using this caddyfile fragment as an example,

:80 {
    reverse_proxy {
        to unix//data/socket
        transport http {
            proxy_protocol v2
        }
    }
}

the generated stream is prefixed with the proxy protocol sequence as defined by haproxy.
See this hex dump:

0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a 20 11 00 0c c0 a8 58 5b 00 00 00 00 00 00 00 00

The 13th byte ("20") is the protocol version and command. The lowest four bits default to 0, meaning LOCAL, but should be initialized to 1, meaning PROXY. Only in this case the receiver uses the information provided in the protocol block to get the original address.

As it stands, the remote address encoded in the header is being ignored by the counterpart.

The related code section is in caddyhttp / reverseproxy / httptransport.go, in function NewTransport().
The section about ProxyProtocol could be simplified by using function HeaderProxyFromAddrs() from the go-proxyproto module.

@mohammed90 mohammed90 added the bug 🐞 Something isn't working label May 5, 2024
@mohammed90 mohammed90 added this to the v2.8.0 milestone May 5, 2024
@mohammed90 mohammed90 added the good first issue 🐤 Good for newcomers label May 5, 2024
@mohammed90 mohammed90 self-assigned this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working good first issue 🐤 Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants