Skip to content

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

@eulores

Description

@eulores

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions