views:

665

answers:

3

I'm thinking of a web app that uses CouchDB extensively, to the point where there would be great gains from serving with the native erlang HTTP API as much as possible.

Can you configure Apache as a reverse proxy to allow outside GETs to be proxied directly to CouchDB, whereas PUT/POST are sent to the application internal logic (for sanitation, authentication...)? Or is this unwise -- the CouchDB built-in authentication options just seem a little weak for a Web App.

Thanks

+1  A: 

Your question is aging without answers, so I'll add this "almost answer".

Nginx can definitely redirect differently based on requests.

This is, if you are ready to place nginx in the front as the revproxy and place apache and couchdb both as backends.

Christian
+1  A: 

Did you see this? OAuth and cookie authentication were checked in on the 4th:

http://github.com/halorgium/couchdb/commit/335af7d2a9ce986f0fafa4ddac7fc1a9d43a8678

Also, if you're at all interested in using Erlang as the server language, you could proxy couchdb through webmachine:

http://blog.beerriot.com/2009/05/18/couchdb-proxy-webmachine-resource/

mwt
+2  A: 

You can use mod_rewrite to selectively proxy requests based on the HTTP method.

For example:

# Send all GET and HEAD requests to CouchDB
RewriteCond %{REQUEST_METHOD} GET|HEAD
RewriteRule /db/(.*) http://localhost:5984/mydb/_design/myapp/$1 [P]

# Correct all outgoing Location headers
ProxyPassReverse /db/ http://localhost:5984/mydb/_design/myapp/

Any POST, PUT, or DELETE requests will be handled by Apache as usual, so you can wire up your application tier however you usually would.

Avi Flax