reverse-proxy icon indicating copy to clipboard operation
reverse-proxy copied to clipboard

RequestHeaderOriginalHost when Host is IP Address

Open BrianBeardOnspring opened this issue 8 months ago • 2 comments

Our application makes use of the Host header and so we use the RequestHeaderOriginalHost option in YARP. But there are certain healthcheck endpoints which get called by IP address and forwarding the IP Address as the Host header causes IIS to return a 400: HTTP Error 400. The request hostname is invalid..

It would be helpful if the RequestHeaderOriginalHost option didn't copy the Host header if it was an IP address or there was an option for that behavior.

BrianBeardOnspring avatar Apr 02 '25 17:04 BrianBeardOnspring

Hello,

Just to be sure to understand, it's IIS that doesn't like having an IP address in the header?

The option seems to be very specific to your use case, I think you can get around with a custom client.

benjaminpetit avatar Apr 07 '25 15:04 benjaminpetit

I'm not really sure if other web servers would have an issue with that or not. I do wonder if it even makes sense to set the host header to an IP address (especially if it is different from what the client is forwarding the request to.) Are there scenarios where that is desirable?

I think more specifically the problem in IIS is when the host header is set to an IP address but the URL is not using an IP address.

BrianBeardOnspring avatar Apr 07 '25 16:04 BrianBeardOnspring