Skip to content

default port in http header 'host' can result in 502 bad gateway #720

Open
@GlenDC

Description

@GlenDC

When proxying traffic via g3proxy over a server type such as http_proxy you can end up with a host header value in the form domain:port. Strictly speaking this is fine and RFC compliant. However there are plenty of reverse proxies out there such as Nginx which do a literal mapping on the host header value to forward the traffic to the appropriate internal service. This won't be able to find a mapping in case a default port is there (E.g. 443 when using https or 80 when using http).

Meaning something like:

Host: www.example.com:443

would result in a 502 status code for such scenarios,
while:

Host: www.example.com

would work.

I can submit a PR if you want but would need some guidance on where you see the appropriate solution for this,
as there are couple of different ways I can see this being solved.

One approach is the sanitizer approach where you might sanitize headers for both h1 and h2 in locations such as lib/g3-http/src/server/request.rs and lib/g3-http/src/server/transparent.rs. For this i can probably provide a patch starting for the host header already where default ports would be stripped.

Another approach could be that you make sure it get fixed for that specific flow. For that I would need guidance and pointers.

I would personally go for the sanitizer approach but wanted to check with you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions