Skip to content

Calling rest endpoint with x-forwarded-host and native forward headers strategy set causes malformed URI #34395

Closed as not planned
@msosa

Description

@msosa

Hi,

My project is using server.forward-headers-strategy: native to apply some x-forward headers. I just upgraded my project to Spring Boot 3.0.3 and am now seeing all my requests with an x-forwarded-host header of localhost:3000 fail with this error

2023-02-27T22:47:30.782+08:00 DEBUG 21608 --- [ctor-http-nio-3] o.s.h.s.r.ReactorHttpHandlerAdapter      : Failed to get request URI: Malformed IPv6 address at index 8: http://[localhost:3000]:3000

I have made a sample repo to show the problem. I tried making a test to show the failure, but the test seems to take a different path then when calling the server directly via postman. You will need to add some headers to postman(curl will also likely work) which are described in the readme.

This works as expected when either using 3.0.2, changing the headers strategy to framework, or just removing the forwarded host header. It does seem that the non problematic calls do not use ReactorHttpHandlerAdapter but rather use HttpWebHandlerAdapter instead.

It does seem weird to me that the port is also included in the x-forwarded-host but there doesn't seem to be a standard way of doing these headers, and that is how the frontend library I am using sets them that way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions