Debugging Javascript with a Reverse Proxy

A few months ago I was exploring the possibility of integrating IBM's Lotus Sametime instant messenger into an installation of Websphere Portal 7 and I had to test some cross domain javascript. As we all know, modern browsers won't allow a javascript request to access a domain which is different from the current.

In this case the javascript provided by the sametime proxy server (running on a different node) contained relative URLs, like /stwebapi/..... Now this is not an issue when running in a production environment because we have a Webseal reverse proxy, but if you need to debug some code on a local machine then you're out of luck. The browser won't issue cross domain javascript requests.

Using Apache as a Reverse Proxy

Turns out that with a few configuration tweaks I can use apache as a reverse proxy. I added the following lines to the bottom of my \Apache2.2\conf\httpd.conf :

ProxyRequests Off

Order deny,allow
Allow from all

ProxyPass /stwebapi http://ghprd01:9081/stwebapi
ProxyPassReverse /stwebapi http://ghprd01:9081/stwebapi

So now any requests to /stwebapi will be redirected to by apache to http://ghprd01:9081/stwebapi, and as far as the browser knows it all comes from the same domain.

Piece of cake!

Comments

Popular posts from this blog

How to Open QR Codes

Jim Henson predicted the end of the world

Mega Giveaway! (Today only!!!)