eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.26k stars 870 forks source link

https-proxy setting from Maven #482

Open sposh opened 8 years ago

sposh commented 8 years ago

From what I understand of the Maven docs proxies/proxy/protocol refers to the protocol of the proxy, not the protocol of the request, and applies to all http connections (including https as well I guess, the docs aren't clear on that) - there doesn't seem to be a way to specify the protocol of the request in Maven (for example to have a different proxy for http and https requests).

Therefore if we set up a proxies/proxy this should set both the proxy and https-proxy parameters in npm install. Right now it only sets up the proxy parameter:

`

local true http localhost 3128

-> [INFO] Found proxies: [local{protocol='http', host='localhost', port=3128}] [INFO] Running 'npm install --proxy=http://localhost:3128' ...`

Should be: [INFO] Running 'npm install --proxy=http://localhost:3128' --https-proxy=http://localhost:3128' ...

Likewise, if we set https as a protocol, as this refers to the proxy protocol, it should set both --proxy and --https-proxy to a proxy on https. Instead it sets a --https-proxy to a proxy on http:

`

local true https localhost 3128

-> [INFO] Found proxies: [local{protocol='https', host='localhost', port=3128}] [INFO] Running 'npm install --https-proxy=http://localhost:3128' ...`

Should be: [INFO] Running 'npm install --proxy=https://localhost:3128' --https-proxy=https://localhost:3128' ...

As a workaround we need to set execution/configuration/arguments in the pom.xml, which is not desired as proxy settings vary from developer to developer.

stevenbower commented 8 years ago

I think you are right about the intent of the maven settings.. generally there seem to be a number of problems with the auto-configuration of proxies in the plugin.. In my environment I have multiple proxies and certain resources that I need to work against (npm repo, maven repos, bower, etc..) are behind the different proxies..

In #474 I tried to address some of this behavior and the PR there could easily be update to support what you're asking for here.. but getting the proxy stuff "right" is a bit harder because for each url for each tool (bower/npm/etc..) you need to be able to pass proxy settings based upon the url they use.. some of which is driven by settings in their own config files (.bowerrc, etc..)

stevenbower commented 8 years ago

Just pushed a patch that fixes this...

sposh commented 8 years ago

Wow, cheers.

stevenbower commented 8 years ago

i think this can be resoled now

aperrot42 commented 7 years ago

I am not sure this is related but proxy settings seem to have a problem being transfered to bower :

my corporated proxy is http:// proxy for both http and https. It seems like it is not correctly passed to bower (it is correctly passed to npm).

Here is an extract of where it starts going wrong :

[INFO] Found proxies: [proxyOrangeGroupe{protocol='http', host='proxy', port=8080}]
[INFO] Running 'npm install --https-proxy=http://proxy:8080 --proxy=http://proxy:8080' in /home/antok/dev/tv_paid_interactivity/report_tv/backend/src/main/resources
[INFO] frontend-project@0.0.1 /home/antok/dev/tv_paid_interactivity/report_tv/backend/src/main/resources
[INFO] └── bower@1.8.0 
[INFO] 
[WARNING] npm WARN frontend-project@0.0.1 No repository field.
[WARNING] npm WARN frontend-project@0.0.1 No license field.
[INFO] 
[INFO] --- frontend-maven-plugin:1.4:bower (bower install) @ backend ---
[INFO] Found proxies: [proxyOrangeGroupe{protocol='http', host='proxy', port=8080}]
[INFO] Running 'bower install --config.proxy=http://proxy:8080' in /home/antok/dev/tv_paid_interactivity/report_tv/backend/src/main/resources
[ERROR] bower                            retry Request to https://bower.herokuapp.com/packages/boosted failed with ECONNRESET, retrying in 1.8s
[ERROR] bower                            retry Request to https://bower.herokuapp.com/packages/boosted failed with ECONNRESET, retrying in 3.8s
[ERROR] bower                            retry Request to https://bower.herokuapp.com/packages/boosted failed with ECONNRESET, retrying in 7.1s
[ERROR] bower                            retry Request to https://bower.herokuapp.com/packages/boosted failed with ECONNRESET, retrying in 15.0s
[ERROR] bower                            retry Request to https://bower.herokuapp.com/packages/boosted failed with ECONNRESET, retrying in 20.1s
[ERROR] bower boosted#3.3.3         ECONNRESET Request to https://bower.herokuapp.com/packages/boosted failed: tunneling socket could not be established, cause=write EPROTO 140240020797248:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:794:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] project1 ............................................ FAILURE [ 54.593 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54.887 s
[INFO] Finished at: 2017-05-16T17:39:24+02:00
[INFO] Final Memory: 19M/422M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:bower (bower install) on project backend: Failed to run task: 'bower install --config.proxy=http://proxy:8080' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
MaxCCC commented 7 years ago

@stevenbower Hi, where do you 'read' the proxy value from? I want to disable the use of my proxy but it remains getting the proxy value and I really don't know from which file it's coming now. I want to run yarn install using my own artifactory but not using the proxy (the proxy is not necessary to connect to my private artifactory)

jicai commented 1 year ago

@stevenbower Hi, where do you 'read' the proxy value from? I want to disable the use of my proxy but it remains getting the proxy value and I really don't know from which file it's coming now. I want to run yarn install using my own artifactory but not using the proxy (the proxy is not necessary to connect to my private artifactory)

This problem puzzled me for some time, and finally found the configuration location **C:\Users\jicai\.m2\settings.xml**

`

optional
  <active>true</active>
  <protocol>http</protocol>
  <host>192.168.2.101</host>
  <port>54750</port>
  <nonProxyHosts>local.net|some.host.com</nonProxyHosts>

`