Apache Proxy for GWT and Alfresco

3 02 2009

Starting with GWT 1.5.3 it is not possible to read data from other servers than local. It makes development a bit tedious since if one was to do a test run of an app it would have to be first compiled (which takes sooo long) and then transferred to the server that all the XMLHttpRequest would be going to. Obviously we need some kind of proxy that will help us to fool the browser. Apache mod proxy fits great. Not to have repeat the same installation and configuration procedure on our all development machines I have created a VMWare vm that contains all the necessary things. Below are the steps that I followed.

  1. Configure NAT interface for VMWare 192.168.100.1/255.255.255.0 (on host machine)
  2. Install Ubuntu server 8.10
  3. Configure /etc/network/interfaces
    # The loopback network interface
    auto lo
    iface lo inet loopback
    # The primary network interface
    auto eth0
    iface eth0 inet static
    address 192.168.100.3
    netmask 255.255.255.0
    gateway 192.168.100.2
  4. sudo apt-get install apache2
  5. Enable http proxy module
    a2enmod proxy_http
  6. Enable virtual hosts
    a2enmod vhost_alias
  7. Allow connections to proxy from all hosts (for convenience) in /etc/apache2/mods-enabled/proxy.conf
    AddDefaultCharset off
    Order deny,allow
    Deny from all
    #Allow from .example.com
    Allow from all
  8. Enable proxy mapping by adding /etc/apache2/sites-enabled/010-proxy:
    <VirtualHost *:80>
        ServerAdmin spam@poland.pl
        ServerName gwtproxy.poland.pl
        ServerAlias gwtproxy
        ErrorLog /var/log/apache2/gwtproxy.poland.pl-error_log
        CustomLog /var/log/apache2/gwtproxy.poland.pl-access_log common
        ProxyPass /pl.poland.cube.Cube http://192.168.100.1:8888/pl.poland.cube.Cube
        ProxyPassReverse /pl.poland.cube.Cube http://192.168.100.1:8888/pl.poland.cube.Cube
        ProxyPass /alfresco http://repo.cube.poland.pl:1030/alfresco
        ProxyPassReverse /alfresco http://repo.cube.poland.pl:1030/alfresco
        DocumentRoot /var/www
    </VirtualHost>
  9. Add to /etc/hosts (on host machine):
    192.168.100.3 gwtproxy gwtproxy.mxts.pl
  10. Edit run configuration in Intellij Idea
    Run configuration in Idea

When run the hosted browser should run app via proxy and it should be possible to read data from http://gwtproxy/alfresco/* which is actually on completely different server.

Sources
Solution on google groups