Skip to content

getRequestHost returns comma separated list of hosts in some proxy setups #992

Closed
@Ingramz

Description

@Ingramz

Environment

N/A

Reproduction

  1. Set up multiple proxies such that Apache HTTP Server is within a chain, for instance the very last proxy before h3:
    User Agent -> Proxy (any, proxy1.tld) -> Apache httpd (proxy2.tld) -> h3

  2. in h3 app, use getRequestHost({ xForwardedHost: true })

  3. Returns proxy1.tld, proxy2.tld

Describe the bug

Some proxies (eg. Apache HTTP Server) append additional hosts to X-Forwarded-Host header when it is part of a multiple proxy chain.

This obscure behavior is thoroughly explained in RicoSuter/NSwag#2370. Due to the non standard nature of the X-Forwarded-Host header, there isn't any authoritative literature to link to, but Envoy proxy documentation corroborates that the hosts should be appended.

In such cases only the first host similarly to X-Forwarded-For header should be returned by the getRequestHost function instead.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions