I'm using Maven 3.1.1 behind a proxy server. The same proxy handles both HTTP
and HTTPS
traffic.
I can't seem to tell maven using settings.xml
to use both protocols. It seems to me that it is only possible to have one active proxy, as whichever active proxy is defined first is used, and subsequent 'active' proxy definitions are ignored. This is my settings.xml
:
<proxies> <proxy> <id>myhttpproxy</id> <active>true</active> <protocol>http</protocol> <host>192.168.1.2</host> <port>3128</port> <nonProxyHosts>localhost</nonProxyHosts> </proxy> <proxy> <id>myhttpsproxy</id> <active>true</active> <protocol>https</protocol> <host>192.168.1.2</host> <port>3128</port> <nonProxyHosts>localhost</nonProxyHosts> </proxy> </proxies>
Is it possible to configure a proxy for both HTTP
and HTTPS
in maven's settings.xml
? I'm aware that I could workaround this by passing Java system properties to the maven invocation such as:
-Dhttps.proxyHost=192.168.1.2 -Dhttps.proxyPort=3128
but surely this must be possible from within settings.xml
?
Maven bugs raised such as MNG-2305 and MNG-4394 suggest this issue is resolved, but I am not convinced.
Alternatively, is there a "proxy proxy" I could run locally that I could point maven to? The "proxy proxy" would route http/https accordingly. Even so, I would still need to define two active proxy definitions in settings.xml
for Maven to direct both types of traffic.
HTTPS proxy can't cache anything as it doesn't see the request sent to the server. With HTTPS proxy you have a channel to the server and the client receives and validates server's certificate (and optionally vice versa). HTTP proxy, on the other hand, sees and has control over the request it received from the client.
The nonProxyHosts setting accepts wild cards, and each host not to proxy is separated by the | character. This matches the JDK configuration equivalent. Please note that currently NTLM proxies are not supported as they have not been tested.
Maven proxy from settings.xml is used for both http and https, so you just need to define one proxy server and it will be used for both, you just need to leave only one proxy
tag, like this:
<proxies> <proxy> <id>myhttpproxy</id> <active>true</active> <protocol>http</protocol> <host>192.168.1.2</host> <port>3128</port> <nonProxyHosts>localhost</nonProxyHosts> </proxy> </proxies>
The protocol above is the protocol of the proxy server, not the proxied request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With