Quick Tip: Developer's Environment Behind a Proxy
From Aventine Solutions
Contents |
[edit] The Problem
I recently had to set up my workstation for Java/J2EE and Oracle development behind a proxy who's use was required for accessing anything out on the Internet. This particular proxy also required Windows NTLM proxy authentication. There were a couple of gotcha's which you may run into:
[edit] Eclipse
In the Eclipse preferences, change the proxy settings under Network Connections (just type "proxy" in the search string to get there quickly). Include the proxy authentication if required. This seems to affect general Internet access for software/plugin updates and getting XML schemas from the Internet. However, the gotcha is that it doesn't affect every plugin, including Subclipse for Subversion if you are using that (read on):
[edit] Subversion and Subclipse
The proxy issue won't bite you if you never use Subversion servers outside the firewall using HTTP or HTTPS (that is to say, these servers use Apache) and you can skip this part.
Usually I install both the command line Subversion (via Cygwin) and the Subclipse plug-in for Eclipse. These both require their own proxy setting which may or may not be shared depending on how you installed them. Additionally, the Eclipse proxy settings will not affect the Subclipse settings as you might think.
For each installation of Subversion, you have to determine the Subversion application settings directory location, usually somewhere under your "home" as .subversion or Subversion. Home can vary depending on which flavor of Windows you are using, so it will take a little digging. In my case, on Windows XP Pro, my home folder is mounted via my domain profile from a network drive and ended up mapped to H:\AppData where I found the Subversion sub-folder. In this folder, you will find the servers file where you can adjust the proxy settings in the global section:
[global] http-proxy-exceptions = localhost http-proxy-host = proxy.this.organization http-proxy-port = 8078 http-proxy-username = myproxylogin http-proxy-password = myproxypassword
Now try to access the external Subversion repository from both Eclipse and the command line. If you are still have problems, it is possible that you have to dig further and find the real servers file that is being used.
With Subclipse, you can specify the home Subversion applications folder in the SVN preferences of Eclipse:
[edit] Maven
I'm not going to talk yet about any Maven plugins for Eclipse, although I am now trying out Maven Q.
For command line Maven, locate the settings.xml file in your MAVEN_HOME (on Windows XP Pro right now, mine settings folder is D:\apache-maven-2.0.9\conf) and edit your proxy setting something like this:
<proxies>
<proxy>
<id>MyOrganization</id>
<active>true</active>
<protocol>http</protocol>
<username>myproxylogin</username>
<password>myproxypassword</password>
<host>proxy.this.organization</host>
<port>8078</port>
<nonProxyHosts>localhost,local.net,some.host.com</nonProxyHosts>
</proxy>
</proxies>
[edit] Rubygems
I also got bitten by a proxy when I tried to use Rubygems. I have not actually fully solved this one, since I have the double whammy of having to use a proxy that requires Windows NTLM authentication and that is not possible with gem ... anyway, if you don't have that problem, just try the http-proxy switch in the command. Note that the proxy value must be in URL format:
gem install rake --http-proxy http://my.proxy.org:8078
As far as the NTLM authentication problem goes, this page from the Rubygems FAQ seems to point at a solution using a local proxy written in Python which can do the authentication, but following the link to SourceForge just gives an error page. I'll have to try this again later.
[edit] RubyOnRails Plugins
Plugins for RubyOnRails are installed by executing an install script from the root of your application, for example:
cd myrailsapp; script/plugin install acts_as_nested_set
When this script does not use the proxy correctly, you'll simply get a not found message. The first step is to set the http_proxy environment variable and try again, for example:
export http_proxy='http://proxy.this.organization:8078'
However, this is not enough if proxy authentication is required. The only thing that worked for me is to hack the open-uri.rb Ruby script in your local installation. First of all, find it:
cd /usr/lib/ruby; find . -iname open-uri.rb
Edit this file and you'll find this on line 216:
klass = Net::HTTP::Proxy(proxy.host, proxy.port)
Pass your proxy user name and password to this function call as hard coded strings:
klass = Net::HTTP::Proxy(proxy.host, proxy.port, 'myproxylogin', 'myproxypassword')
[edit] Mercurial
Find the .hgrc under your home directory. This depends on how you installed it, but for Cygwin users like myself, it will be in your ${HOME} folder. Edit this file and add the [http_proxy] section, for example:
[ui] username = Matthew Eichler <matthew.eichler@aventinesolutions.nl> [http_proxy] host = proxy.thisorganization.net:8078 user = mylogin passwd = mypassword no = localhost
[edit] Versions
Software versions I'm using at the time of this writing:
| Windows | XP Professional Service Pack 2 |
| Eclipse | Europa 3.3.0 M20070921-1145 |
| Subversion | 1.4.3 (I also use on this workstation Tortoise SVN 1.4.3) |
| Subclipse | Subversion Client Adapter 1.5.0 |
| Maven | 2.0.9 |
| Maven Q | DevZuz 0.7.0.200805270033 |
| Rubygems | 1.2.0 |
| RubyOnRails | 2.3.2 |
| Mercurial | 1.0.2 from Cygwin |


