Friday, 8 November 2013

Using Apache proxy for Rails / GWT interaction

In my earlier blog about using Rails with GWT, I use Apache's proxy mechanism to bridge the two. So you would put in:
 into your browser and it would route / to your rails server running on port 3000 and it would route another URL (e.g. /MainApplication) to your GWT server running in Eclipse (e.g. http://localhost:8888/MainApplication)

Quite a few people seem to have a problem with the apache proxy config. So here is how I do it on Kubuntu.

I have the standard Kubuntu setup which http2. I also have the proxy module installed (use the Ubuntu/Kubuntu installers for this if you don't have it as a default).

You will find this directory:

In it, create this file: 010-proxy.conf
Note: In the later versions of Apache on Ubuntu you have to have your files end in .conf else they won't be loaded.

And in the file, place YOUR version of this (note that my GWT app is called mainApplication and runs on port 8888 and my Ruby on Rails app runs off root on port 3000):

ServerAlias localhost
ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ common

ProxyHTMLLogVerbose On
LogLevel Debug

ProxyPass /mainApplication.html http://localhost:8888/mainApplication.html
ProxyPassReverse /mainApplication.html http://localhost:8888/mainApplication.html

ProxyPass /mainApplication.css http://localhost:8888/mainApplication.css
ProxyPassReverse /mainApplication.css http://localhost:8888/mainApplication.css

ProxyPass /MainApplication http://localhost:8888/MainApplication
ProxyPassReverse /MainApplication http://localhost:8888/MainApplication

ProxyPass /sc/ http://localhost:8888/MainApplication/sc/
ProxyPassReverse /sc/ http://localhost:8888/MainApplication/sc/

ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/

DocumentRoot /var/www

No comments:

Post a Comment