http-add-on icon indicating copy to clipboard operation
http-add-on copied to clipboard

Ensuring that the proper host is set on all Location headers

Open arschles opened this issue 2 years ago • 5 comments

This PR changes the behavior of the interceptor when the app returns a Location header that does not have a host on it (i.e. Location: "/abc").

Prior to this patch, the interceptor simply passed this value back to the client, but now, it ensures that the incoming host value is prepended to the final header. This new behavior ensures that in all circumstances where an app intends to return a Location header, a Location header will be returned to the client with the proper hostname in it.

Checklist

  • [x] Commits are signed with Developer Certificate of Origin (DCO)
  • [x] Any necessary documentation is added, such as:

Fixes #331

arschles avatar Feb 18 '22 21:02 arschles

@obito @benjaminwood here is a proposed solution to #331. A short overview of what this is doing is in the description of the PR above. is in the Can you folks take a look and let me know what you think?

An alternative to this PR is to avoid overwriting the request host here (similar to something you suggested @obito). I'd like to hear what you both think about that also, if you don't mind.

cc/ @asw101

arschles avatar Feb 18 '22 22:02 arschles

I'll try it out and follow up!

benjaminwood avatar Feb 21 '22 02:02 benjaminwood

@benjaminwood thank you kindly!

arschles avatar Feb 23 '22 23:02 arschles

Any follow up on this ?

obito avatar Oct 31 '22 09:10 obito

@arschles Hi! I just stumbled across this issue and instead of opening a new one, it might make sense to follow up on this one first: I think I have a scenario where the original host header should have been kept while forwarding the request to the target pod:

I have a web service that is hostname-aware and changes behavior based on it. Unfortunately it cannot be configured to use the x-forwarded-for header, which indeed contains the correct, original request hostname.

For example: My original request was https://foo.bar.com. Without KEDA (Only with nginx ingress) my target pod sees "foo.bar.com" as the hostname (no x-forwarded-for header is set). After enabling KEDA with the http-add-on the target pod only sees "foo.default".

Is there a way to configure that behavior so the proxy preserves the original hostname? Thanks in advance - max

proligde avatar May 09 '23 09:05 proligde