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

[upstream policy] use the default port (by scheme) for the upstream url #647

Closed
wants to merge 1 commit into from

Conversation

mayorova
Copy link
Contributor

@mayorova mayorova commented Mar 7, 2018

This fixes the following issue:

when the URL in the upstream policy is set to https://something, the port is nil, and so https://github.com/3scale/apicast/blob/2affe4e40e268841b489cf06c229a66ac9aa9749/gateway/src/resty/balancer.lua#L33 will set it to 80. As a result APIcast will try to reach https://something:80 and fail.

Couldn't figure out how to test this yet... some help would be appreciated @davidor @mikz 🙏

@mayorova mayorova changed the title [upstream policy] use the default port (by scheme) for the upstream url [WIP][upstream policy] use the default port (by scheme) for the upstream url Mar 7, 2018
@mayorova mayorova force-pushed the default-port-for-upstream-policy branch from 3907d1d to f877522 Compare March 7, 2018 18:34
@mayorova mayorova force-pushed the default-port-for-upstream-policy branch from f877522 to 80f00d9 Compare March 7, 2018 18:35
@mayorova mayorova changed the title [WIP][upstream policy] use the default port (by scheme) for the upstream url [upstream policy] use the default port (by scheme) for the upstream url Mar 7, 2018
@mayorova mayorova requested review from davidor and mikz March 7, 2018 18:35
@@ -27,7 +27,7 @@ end

local function change_upstream(url)
ngx.ctx.upstream = resty_resolver:instance():get_servers(
url.host, { port = url.port })
url.host, { port = url.port or resty_url.default_port(url.scheme) })
Copy link
Contributor

@davidor davidor Mar 8, 2018

Choose a reason for hiding this comment

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

I think this can't be here. When a port is passed here, it overwrites the one set by the resolver.
That's why the sanity.t integration test fails. That test uses the upstream policy:

      "policy_chain": [
        { "name": "apicast.policy.upstream",
          "configuration": { "rules": [ { "regex": "/", "url": "http://echo" } ] } }
      ]

In that case, when resty_resolver resolves echo, it includes a port (randomly generated by the test framework in this case), and your solution overwrites it with 80.

I think the port should be set only when it's not set by the resolver.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidor how about #662?

@mayorova
Copy link
Contributor Author

mayorova commented Apr 3, 2018

Closing in favor of #662

@mayorova mayorova closed this Apr 3, 2018
@mikz mikz deleted the default-port-for-upstream-policy branch April 3, 2018 21:51
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.

3 participants