Skip to content

ForwardedRequestCustomizer uses connection port instead of proto default when host lacks port #13970

Closed

Description

@zenios

Description
In a Forwarded header such as:
Forwarded: by=203.0.113.43; for=198.51.100.17; host=example.com; proto=https

Jetty currently assumes that it should use the connection port rather than inferring the default port for the proto scheme.

See implementation:
ForwardedRequestCustomizer.java#L535

When Jetty is deployed behind a reverse proxy and listens on port 8084, this results in the request authority being interpreted as:

example.com:8084

instead of the expected:

example.com

(since the proto=https implies port 443 by default).

The relevant RFCs (RFC 7230 and RFC 9112) describe default-port behavior for URIs and authority forms, though none explicitly define it for the Forwarded header. However, other implementations such as Vert.x’s ForwardedParser resolve the missing port to the default port corresponding to the proto scheme.

Expected behavior:
When the host parameter in a Forwarded header does not include a port, Jetty should use the default port associated with the proto scheme (80 for HTTP, 443 for HTTPS), rather than the local connection port.

Actual behavior:
Jetty uses the connector’s local port (e.g., 8084), resulting in an incorrect authority.

Environment:
Jetty version 12.1.3

Notes:
This behavior causes incorrect redirects and absolute URL reconstruction behind reverse proxies when relying on Forwarded headers.

Activity

  1. added
    BugFor general bugs on Jetty side
    on Nov 4, 2025
  2. joakime commented on Nov 4, 2025

    @joakime
    Contributor

    What is your HttpConfiguration.getSecurePort() set to on the connector that handles that request?

  3. zenios commented on Nov 4, 2025

    @zenios
    ContributorAuthor

    I dont set that since.I only listen to 8084 unsecured behind nginx and nginx is the one that does the ssl termination and forward to jetty

  4. moved this to 🏗 In progress in Jetty 12.1.12 - Badon Jul 7, 2026
  5. added a commit that references this issue on Jul 9, 2026
    a376f45
  6. moved this from 🏗 In progress to ✅ Done in Jetty 12.1.12 - Badon Jul 9, 2026
  7. added a commit that references this issue on Jul 9, 2026
    090a299
  8. added a commit that references this issue on Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFor general bugs on Jetty side

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions