Wednesday, January 1, 2014

Transparent proxy and Maven Archetype plugin under Eclipse Juno

Recently I had a problem installing the Gatling stress tool under Eclipse JunoSR2 on a 12.04 Ubuntu development VM. Being located behind my enterprise proxy, it was impossible for me to download the Gatling archetype catalog, and thus to create Gatling projects within Eclipse.
http://www.squid-cache.org/

My Maven settings.xml file contained the required settings for proxyfication, and as a matter of fact, things worked well outside Eclipse (including archetype catalog download via the proxy).

Inside Eclipse, Maven was OK ... exception made for the component in charge of downloading remote archetypes catalogs. It ignored my proxyfication setup trying constantly to download things directly from the Internet and failing because my computer is on a private network and not natified.

I used the following trick to workaround this:

  • Installation of the squid proxy server on the VM
  • Setup of the squid server as a transparent proxy whose parent proxy is my enterprise proxy
  • Configuration of the iptables in order to redirect to Squid any request made to the 80 port, excluding destinations on my internal network 

Here is the squid.conf file:

http_port 3128 transparent
http_access allow all
cache_peer proxy.mycompany.com parent 8080 0 no-query no-digest
never_direct allow all

And the iptables rules required (starting from a null list):

iptables -t nat -A OUTPUT -p tcp --dport 80 -d 192.168.0.0/16 -j ACCEPT
iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-port 3128

The first rule aims at bypassing any transparent proxyfication for internal http trafic, the second one magically redirects any http outcoming request to the local squid which delegates any request  to the enterprise proxy.

All of this work with the usual proxyfication setting.