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

foo.bar.domain.com shouldn't be proxied if no_proxy has .domain.com item #2160

Closed
mapleeit opened this issue May 21, 2019 · 8 comments
Closed

Comments

@mapleeit
Copy link

Describe the bug

foo.bar.domain.com would still be proxied if no_proxy env has .domain.com item.

Related code is here:

proxyElement.match(/\./g).length === parsed.hostname.match(/\./g).length) {

foo.bar.domain.com has 3 dots. On the contrary, .domain.com has 2 dots. So it will not match.

request uses indexOf, which supports this.

var isMatchedAt = hostname.indexOf(noProxyZone.hostname)
var hostnameMatched = (
  isMatchedAt > -1 &&
    (isMatchedAt === hostname.length - noProxyZone.hostname.length)
)

Wondering that is this a but or it's a original designing. If it's a bug, I'm willing to make a PR.

To Reproduce

set system envariable:

export HTTP_PROXY=http://test.proxy.com
export http_proxy=http://test.proxy.com
export HTTPS_PROXY=http://test.proxy.com
export https_proxy=http://test.proxy.com
export NO_PROXY=.domain.com
export no_proxy=.domain.com
axios.get("http://foo.bar.domain.com")
.then(data => console.log(data))
.catch(e => console.log(e))

Expected behavior
Shouldn't proxied.

Environment:

  • Axios Version [e.g. 0.19.0-beta.1]
@mapleeit mapleeit added the bug label May 21, 2019
@mapleeit
Copy link
Author

I just found that there is already a PR to solve this. #1880

@rjoaopereira
Copy link

rjoaopereira commented Jun 26, 2019

I would like to ask the original author (@chancedickson ) for the rationale behind this comparison.

I also found this problem and I'm interested in seeing if this is by design.

@cawoodm
Copy link

cawoodm commented Dec 5, 2019

We also noticed today that Axios will proxy 127.0.0.1 even if we have NO_PROXY=127.0.0.*. It seems Axios (unlike fetch) does not understand wildcards.

@cawoodm
Copy link

cawoodm commented Dec 5, 2019

So Axios understands suffixes (without *) - NO_PROXY=.mydomain.com will match myhost.mydomain.com but you cant get a prefix like NO_PROXY=127.0.0. to work no matter which way you turn it.

@nabeelamirch
Copy link

Yes it doesn't work with wildcard e.g. *.domain.com will not match foo.domain.com. Could we do something like this:

if (proxyElement.includes("*")) {
   return new RegExp("^" + rule.replace("*","[a-zA-Z_0-9]")+ "$")).test(str);
}

Over here:

shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {

@mapleeit
Copy link
Author

mapleeit commented Apr 1, 2020

0.19.1 already solved this problem, I'm closing this issue.

@mapleeit mapleeit closed this as completed Apr 1, 2020
@nabeelamirch
Copy link

I agree with the above, so I will raise another one with the wildcard issue

@nabeelamirch
Copy link

I have raised #2864

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants