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

Roundrobin overwrites request URL #40

Open
mikaelnousiainen opened this issue Apr 4, 2016 · 2 comments
Open

Roundrobin overwrites request URL #40

mikaelnousiainen opened this issue Apr 4, 2016 · 2 comments

Comments

@mikaelnousiainen
Copy link

It seems that using roundrobin in a way that is similar to the example in README does not work correctly -- or at least it does not work the way I expect it to.

We have the following code:

fwd, _ := forward.New()
lb, _ := roundrobin.New(fwd)

lb.UpsertServer(url1)
lb.UpsertServer(url2)

s := &http.Server{
    Addr:           ":8080",
    Handler:        lb,
}
s.ListenAndServe()

Where:

Let's consider the following scenario:

  1. Server receives request: http://server/path/to/a/file.txt
  2. Roundrobin gets a suitable server from the list using code and sets the URL for forwarder in: https://github.com/vulcand/oxy/blob/master/roundrobin/rr.go#L72
  3. The URL for forwarder is either: "http://backend1:8080/" or "http://backend2:8080/", while I would have expected it to be: "http://backendN:8080/path/to/a/file.txt"

I cannot see how the code is supposed to be used to achieve a trivial reverse proxy setup.

Is there something I've missed? :)

@mikaelnousiainen
Copy link
Author

Ok, I found out that forward uses RequestURI to replace url.Opaque, but in this case the RequestURI should contain also the host, which is not the case, so I still don't understand how this is supposed to work considering the following:

"RequestURI is the unmodified Request-URI of the Request-Line (RFC 2616, Section 5.1) as sent by the client".

Additionally, URL.String() ends up with scheme:opaque?query#fragment.

@lunemec
Copy link

lunemec commented Jan 19, 2017

This is dupliacte with #57. This issue was first, but the #57 has some proposed solutions. This should be closed as dupliacte and solved there.

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

No branches or pull requests

2 participants