Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy header handling 2 #72

Closed
wants to merge 7 commits into from

Conversation

smancke
Copy link
Contributor

@smancke smancke commented Mar 31, 2016

Here is a more clean implementation of the former pull request #67.
Please look over it and tell me, what you think about it, now.

I was unsure, if I should add a user documentation on the headers to the readme?
Maybe it's to much detail for the readme?

@@ -8,6 +8,16 @@ import (

func newHTTPProxy(t *url.URL, tr http.RoundTripper) http.Handler {
rp := httputil.NewSingleHostReverseProxy(t)

originalDirector := rp.Director
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain better in the comment why this is necessary and which problem it solves? Also, s/originalDirector/d/

@magiconair
Copy link
Contributor

Looks OK. Some minor nitpicks in formatting and naming. Is there a way to squash the commits into one before submitting? I don't need/want the full history on how we got there. (used to gerrit)

@smancke
Copy link
Contributor Author

smancke commented Apr 1, 2016

OK, I have done the style changes.
Squashing everything together to one commit is no problem, if everything is final.

But I got one question in mind, concerning the host header change, I made to the
director of the SingleHostReverseProxy.
I think, my implementation is on the http standard and also the common way how e.g. nginx behaves. But, if someone is relying on the current behavior of fabio, than it's code may break. It would be an option, to make the behavior configurable with the current state as default. But this would mean that the default behavior of fabio would stay in being not correct.
So the decision is: Correct by default vs. full backwards compatible.

@magiconair
Copy link
Contributor

If I understand the host header change correctly then this behaves as follows:

Given the route route add srv xxx.com/foo http://yyy.com/ the current implementation would forward with the Host header set to xxx.com and your change would change that to yyy.com, correct?

If that is the case than I cannot merge this since it would break our app big time. We rely on the original host header to be present. This discussion is along the same line I have with people asking for path prefix stripping. By doing this you move a central piece of configuration into the LB and you rely on this function to be there. Without that your application does not work.

fabio is trying hard not to do that by not offering these options as the app should work the exactly same with and without fabio. This means that an app should handle all routes and it should also understand all host names. I understand that other LBs offer this but I think this should be solved in the app itself. Please let me know whether I understood this correctly.

@magiconair
Copy link
Contributor

Also, I don't think that this behavior is "correct" since it depends on what the LB is supposed to be doing. Sure, you can rewrite the host header but if the application needs to generate links that contain the full external host name then you would have to configure that separately since it can't extract that information from the request anymore. IMO, the whole path mangling is the wrong approach. Just like NAT on the IP level. It works but it causes all kinds of problems downstream.

@smancke
Copy link
Contributor Author

smancke commented Apr 3, 2016

Hi @magiconair magiconair,
yes, you understood this correctly.

In my opinion it would be a bad practice, not to rewrite the host header, since this is how http usually woks in such an architecture. If an application wants to construct the url's, it has to respect the Forwading header. Every serious framework is doing so. Even without rewriting, you have to respect the headers, for the correct protocol scheme (http/https).

But the world is full of opinions ;-)
So, please decide, how it should be:
a) Should I make the rewrite of the host header configurable, with the current behavior as the default?
b) Or should I remove the host header rewriting from the pull request?

@magiconair
Copy link
Contributor

Lets leave it out for now. I need to think about this a bit more and TBH so far nobody has complained about it but I'd like to stick to RFCs where possible. Can you add another issue about this? Then we can have that discussion there.

If I understand correctly I should be able to do the squashing in github now. Lets try that.

Thank you

@smancke
Copy link
Contributor Author

smancke commented Apr 6, 2016

Here #74 is a new pull request with the squashed commits, excluding those which are relevant to host header. (I also removed the code for X-Forwarded-Host and so, since it is only needed if we would rewrite it.)

An Issue for the Host Header thing is created at: #75

@smancke smancke closed this Apr 6, 2016
@magiconair magiconair mentioned this pull request May 9, 2016
magiconair added a commit that referenced this pull request May 9, 2016
* The X-Forwarded-For header is currently not set for websocket
  connections which is probably a regression of #72.

* The X-Forwarded-Proto header should be set to ws and wss for
  websocket connections.

* The X-Forwarded-Port header should be set to complete the
  X-Forwarded-* headers.

* The Forwarded header should set proto to either ws or wss
  for websocket connections.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants