Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Proxy prefers https variant, regardless of phantomjs_cdnurl scheme or no_proxy setting. #797

Open
inflammable opened this issue May 15, 2018 · 0 comments

Comments

@inflammable
Copy link

inflammable commented May 15, 2018

We've hit a strange problem where phantomjs-prebuilt will attempt to use a proxy for a server that doesn't require proxy access, and will use the wrong proxy for the http scheme specified in phantomjs CDN URL. In part this seems to be because of the way node/npm prioritises environment variables over the .npmrc in the project.

In the scenario that:

  • phantomjs_cdnurl is defined with an http:// address (i.e. that server resides on an internal network),
  • https_proxy is defined in the environment
  • no_proxy is defined in the environment and includes the domain name for phantomjs_cdnurl

Assuming the code at https://github.com/Medium/phantomjs/blob/master/install.js#L154 is where this is setup - that behaviour makes sense.

Ideally the use of a proxy would be based on:

  • whether or not the scheme and hostname (and maybe port?) in phantomjs_cdnurl (or options.uri) appears in no_proxy

And the type of proxy would be based on:

  • the scheme supplied in phantomjs_cdnurl (or options.uri)

As a slightly obfuscated example of it failing today:

$ export npm_config_https_proxy="https://https.proxy.internal:8080/"
$ export npm_config_no_proxy="localcdn.internal"
$ npm install phantomjs-prebuilt --phantomjs_cdnurl=http://localcdn.internal/npm

> phantomjs-prebuilt@2.1.16 install /.../node_modules/phantomjs-prebuilt
> node install.js

PhantomJS not found on PATH
Downloading http://localcdn.internal/npm/phantomjs-2.1.1-macosx.zip
Saving to /.../phantomjs/phantomjs-2.1.1-macosx.zip
Using proxy https://https.proxy.internal:8080/
Using npmconf ca
Receiving...
^C
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

1 participant