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

reverseproxy: always set the req.URL.Host with the upstream #3290

Closed
wants to merge 1 commit into from
Closed

Conversation

westwin
Copy link
Contributor

@westwin westwin commented Apr 21, 2020

Issue Description: reverse proxy with round-robin policy always forwards the traffic to one upstream node.

How to Reproduce:

  1. set up upstream http service with two nodes(keep-alive enabled, on port 9010 and 9020)
  2. set up caddy as a reverse proxy with config:
    :2015 {
    reverse_proxy /* 127.0.0.1:9010 127.0.0.1:9020 {
    lb_policy round_robin
    lb_try_duration 100ms
    lb_try_interval 250ms
    }
    }
  3. run the reverse proxy, and do a infinite loop test against :2015 to see the traffics are round-robin forwarded to 9010/9020
  4. during the test, kill the service on 9010, and restart 9010
  5. check the traffics will never forward to 9010, which always sticks to 9020

Test on macos

@CLAassistant
Copy link

CLAassistant commented Apr 21, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Feng Xi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@francislavoie francislavoie changed the title fix: always set the req.URL.Host with the upstream reverseproxy: always set the req.URL.Host with the upstream Apr 21, 2020
@francislavoie
Copy link
Member

@mholt
Copy link
Member

mholt commented Apr 21, 2020

Thanks for the PR!

I don't know what I was thinking when I wrote that if statement. It seems to go way back to this commit, waaay early (or before?) the beta versions: 0830fba#diff-3820b4f14e2fee163a1894dbf2560bd9R476

It makes sense to remove it, since if the first request fails, it will try with the second backend, but the req.URL.Host will already be set to the host of the first backend 🤔

So... I do think this fixes a bug. It's a pretty minor change, and I've confirmed it works in a few various configurations, and you've confirmed it works for you, too. I think we can get this out in v2.0.

Any objections? @francislavoie @sarge

@mholt mholt added this to the v2.0.0 milestone Apr 21, 2020
@mholt mholt added the bug 🐞 Something isn't working label Apr 21, 2020
Copy link
Member

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

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

Seems fine to me.

@mholt
Copy link
Member

mholt commented Apr 21, 2020

@westwin Before we can merge, we need you to sign the CLA.

@sarge
Copy link
Collaborator

sarge commented Apr 21, 2020

Looks fine to me:)

@francislavoie
Copy link
Member

francislavoie commented Apr 22, 2020

@westwin for the CLA, you'll need to either add your email address fengxi@fengxi.com to your westwin Github account as a secondary email address on this settings page, or make the commit again after having configurted git with an email address that's already on your account (see the settings page to see which ones you have)

@westwin
Copy link
Contributor Author

westwin commented Apr 22, 2020

@westwin for the CLA, you'll need to either add your email address fengxi@fengxi.com to your westwin Github account as a secondary email address on this settings page, or make the commit again after having configurted git with an email address that's already on your account (see the settings page to see which ones you have)

I've re-submitted as I used a fake email address in my git config, see #3297

sorry for the inconvenience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants