I've two servers on my small local machine. The first is a JBoss server running on port 8080 and also the other is really a CouchDB server running on port 5894. I'm able to access all of them at localhost:8080 and localhost:5984 correspondingly. Because of ajax same-domain restriction, I have to access both jboss and couchdb from example.com or at best the couchdb from example.com/couch. I heard and browse that apache's reverse proxy config can sort out this. But to date I'm not able to have it working. I'm running apache 2.2.19 on Win32. Can someone assist with the config to do this?

If you work with CouchDB v1.1., it features a built-in proxy. Possibly it may be most of your web server, handling some queries and sending the relaxation to JBoss? You will find some limitations, mainly that you don't possess the sophisticated control like httpd mod_rewrite gives you.

Log to the Futon administration interface (/_utils). Within the configuration section, click "Give a new section" in the very bottom. The section is httpd_global_handlers the choice can be you, for instance: /_jboss and also the value is definitely an Erlang expression, {couch_httpd_proxy, handle_proxy_req, <<"">>}. (Clearly you are able to choose any URL you would like but this situation should work.)

You may also set this directly within the HTTP API:

PUT /_config/httpd_global_handlers/_jboss HTTP/1.0
Content-Type: application/json

"{couch_httpd_proxy, handle_proxy_req, <<\"\">>}"

Now whenever you query CouchDB, everything is like before. However, there's a brand new URL space /_jboss/* that will proxy directly through CouchDB and also to JBoss.

If you want JBoss to become at / and CouchDB to become at /couch that's also possible utilizing a CouchDB vhost and some rewrite rules. (They're easier than Apache httpd mod_rewrite).

mod_proxy module then one such as this?

ProxyPass /couch/ http://localhost:5894/
ProxyPassReverse /couch/ http://localhost:5894/

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/