Can't use Maven through a proxy with a Vagrant machine - maven

I'm currently using JHipster on their DevBox (XUbuntu) through a proxy.
I configured everything I could think about in it to use it through a proxy, mainly with the vagrant-proxyconf plugin and by exporting MAVEN_OPTS in a shell script inside /etc/profile.d.
npm install works fine, same for apt-get or Firefox.
However, mvn, telnet or ping keep giving me "Connection timed out" errors, with repo1.maven.org or google.com, even if I give the proxy options as parameters of mvn directly.

Ok found the problem...
To use Maven through a proxy you can set the MAVEN_OPTS environment variable like this: -Dhttp.proxyHost=<domain> -Dhttp.proxyPort=<port> -Dhttps.proxyHost=<domain> -Dhttps.proxyPort=<port> for a proxy URL like this: <protocol>://<domain>:<port>.
I simply used <protocol>://<domain> instead of <domain>...
But ping and telnet still won't work, even if the HTTP(S)_PROXY environment variables, lower and uppercase, are set. Well, I don't really need them so it's just strange but not harmful.

Related

MacOS : brew install package throws a proxy issue in terminal

I am banging my head trying to find out from where is the proxy being read from.
Here is the background. I am trying to do brew install wget on the Mac terminal
However, I immediately get fatal: unable to access 'https://github.com/Homebrew/brew/': Failed to connect to xxxxproxy.proxy.proxy.com port 8080: Connection refused
I tried to remove the HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, http_proxy, https_proxy, all_proxy. When I run echo $xxxxx_proxy for all the above variables, I get blank values, indicating that the proxies are unset.
Where is this proxy being read from? Any help/guide would be really appreciated. Thank you!
Edit: I might have posted a very silly question, or maybe the question is a duplicate (which I am not able to find here). If so, I apologize in advance :)
It seems that the .gitconfig file in my home /Users/<username>/.gitconfig had the proxy values set within it. As soon as I commented those, everything started working smoothly.
#[http]
# proxy = xxx.xxx.xxx.com:80
#[https]
# proxy = xx.xxx.xxx.com:80
To use brew package behind a proxy you should set variable ALL_PROXY
export ALL_PROXY=proxyIP:port
If you want to remove the proxy definition and use direct connection execute in terminal:
unset ALL_PROXY
and in the same terminal execute the command

How to Access Jenkins Remotely from Maven Run

Since manually executing steps of my plugin with demo projects takes some time, I'd like to execute it on a separate server using mvn hpi:run. To access Jenkins on my desktop, I'd like to tunnnel e.g. using ssh server -L 8080:server. Unfortunately, I cannot access the server with tunnelling and even on the server itself, curl localhost:8080 works and curl server:8080 does not work (and ssh server works, so it is not a connection problem).
Since ufw is disabled, I assume that the Jenkins which is run by maven usually only listens to 127.0.0.1. To change this, according to https://wiki.jenkins.io/display/JENKINS//Starting+and+Accessing+Jenkins, either setting --httpListenAddress=0.0.0.0 or setting $HTTP_HOST should be possible (https://serverfault.com/questions/408657/how-to-access-jenkins-remotely-on-ubuntu-12-04-server).
Unfortunately, both versions
mvn clean hpi:run -DhttpListenAddress=0.0.0.0
export HTTP_HOST=0.0.0.0 && mvn clean hpi:run
did not succeed. Additionally, I guessed -Djetty.host=0.0.0.0 could work (how to make jetty server accessible from LAN?) since the port of Jenkins can be set using -Djetty.port, but it also did not work:
mvn clean hpi:run -Djetty.host=0.0.0.0
Is there any option to make a Jenkins plugin directly remote accessible when using hpi:run, or is it necessary to deploy it to a local Jenkins server everytime?
Following worked for me:
mvn -Dhost=0.0.0.0 hpi:run

How to use socks with gradle for dependency resolving, in command line?

When jcenter is not accessible without proxy server, to resolve dependencies, and i want to use socks instead of http proxy, how i can use it in commanad line?
I know how to use http proxy:
-Dhttp.proxyHost=yourProxy -Dhttp.proxyPort=yourPort
-Dhttp.proxyUser=usernameProxy -Dhttp.proxyPassword=yourPassoword
I found answer, here you can use:
./gradlew -DsocksProxyHost=yourHost
-DsocksProxyPort=yourHostPort your-command
using above you can set socks host and port.
Gradle only documents about how to use HTTP(s) proxy, however in the ant source code it mentions, there is enough information about how to setup the SOCKS proxy.
Add the following two lines to the gradle.properties configuration file and you are done.
systemProp.socksProxyHost=your socks proxy ip
systemProp.socksProxyPort=your socks proxy port
The format of SOCKS configuration names (socksProxyHost and socksProxyPort) differs from HTTP proxy host and port configurations (http.proxyHost and http.proxyPort).
Refering to https://discuss.gradle.org/t/how-can-i-set-gradle-proxy-to-socks/15508
In the Project window change from Android to Project scope.
Then open up gradle.properties and add this line:
org.gradle.jvmargs=-DsocksProxyHost=yourHostIP -DsocksProxyPort=yourHostPort
Sync project.
i might be a little late but i found out that in ubuntu/Linux the proxy settings are cached in ~/.gradle/gradle.properties and I also found out that this gradle.properties is different from the one in your app inside android studio.
so you need to edit the credentials in there.
do a vim ~/.gradle/gradle.properties and edit the credentials there.
in my case i was using a socks proxy so i commented out all the http and https proxy hosts and ports and added one for socks. it looked like this
`systemProp.socks5ProxyHost=127.0.0.1
systemProp.socks5ProxyPort=1080`
i was able to sync gradle afterwards.

Configuring mercurial to use a proxy gives error "abort: error: ''"

Adding a proxy section to my ~/.hgrc file doesn't seem to work, nor does
setting the proxy on the command line; e.g.
$ hg --config=http_proxy.host=http://127.0.0.1:8181 incoming
The proxy section in my ~/.hgrc file looks like:
[http_proxy]
host=http://localhost:8181
Instead, I get a not so informative response printed to stderr:
abort: error: ''
After some investigation, (adding --debug --traceback) I found this error
happens in the keepalive.py file of one of the underlying python library files.
I have Firefox/foxyproxy set up to use this same proxy, and everything works
fine - the port number [and host] is correct.
After a few minutes I realised my proxy is set up as a socks proxy, and that
mercurial doesn't work with socks proxies. The fact that the section heading is
http_proxy was the give-away hint.
I installed polipo, set it to use the socks proxy as it's parent, and
configured mercurial in the ~/.hgrc file to use this proxy instead.
Everything is working nicely now. (And I've also set firefox to use it instead
as it caches files as required too).

How do I enable dependency management for PlayFramework behind a proxy?

Hi all
I'm trying to add new dependency to Play application, but it fails to resolve dependencies. I've added a line:
- org.fusesource.scalate -> scalate-core 1.4.1
Now when I'm trying to run 'play dependencies --verbose' I receive following:
Server access Error: Network is unreachable: connect url=http://repo1.maven.org/maven2/org/fusesource/scalate/scalate-core/1.4.1/scalate-core-1.4.1.pom
Server access Error: Network is unreachable: connect url=http://repo1.maven.org/maven2/org/fusesource/scalate/scalate-core/1.4.1/scalate-core-1.4.1.jar
This is because of a corporate proxy. I can't figure out how to configure Play (from output I assume it uses Ivy for Dependency management) to use proxy. Still python scripts like 'play install' work ok.
Thanks
Apparently ivy uses ant's setproxy which simply add some system options...
Can you try something like:
#> play deps YOUR_PROJECT_DIR -Dhttp.proxyHost=YOUR_PROXY -Dhttp.proxyPort=YOUR_PORT
My solution is:
play dependencies --sync --verbose -Dhttp.proxyHost=YOUR_PROXY
-Dhttp.proxyPort=YOUR_PORT
-Dhttp.proxyUser=YOUR_USERNAME -Dhttp.proxyPassword=YOUR_PASSWORD
and if you use a proxy script instead, use the same solution as ProgrammerX, but just substitute the URL for the script:
set HTTP_PROXY=http://your-proxy-script-server/ProxyScript.pac
Another simple way on windows is to simply set HTTP_PROXY in the environment properties or on the command like as so
set HTTP_PROXY=http://proxy server:port

Resources