Apache as a reverse proxy for CouchDB

I am referring to a web application that makes extensive use of CouchDB to such an extent that it would be possible to make great progress from working with the erlang HTTP native API.

Can you configure Apache as a reverse proxy to allow external GET addresses to connect directly to CouchDB, while PUT / POST are sent to the application’s internal logic (for sanitation, authentication ...)? Or is it unreasonable - CouchDB's built-in authentication capabilities seem a bit weak for a web application.

thanks

+4
source share
4 answers

You can use mod_rewrite for a selective proxy request based on the HTTP method.

For instance:

 # 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 processed by Apache as usual, so you can connect your application tier, as a rule, usually.

+4
source

Your question is aging unanswered, so I will add this “almost answer”.

Nginx can definitely redirect in different ways based on requests.

This is if you are ready to place nginx at the beginning as revproxy and put apache and couchdb as your backend.

+1
source

Did you see that? OAuth and cookie authentication was verified on 4th:

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

In addition, if you are generally interested in using Erlang as a server language, you can proxy couchdb through webmachine:

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

+1
source

I would think about using the Apache mod_proxy reverse proxy function. Create a virtual host configuration that forwards specific web server HTTP requests to CouchDB. You can configure the rules by which URI paths should be redirected, etc.

See this guide for inspiration: http://macgyverdev.blogspot.se/2014/02/apache-web-server-as-reverse-proxy-and.html

-1
source

All Articles