Using NGINX as a front-end server to forward to multiple back-end services works great by configuring NGINX as a reverse proxy. The reverse proxy configuration will have NGINX serve HTTP/HTTPS URLs and forward them to them to network addresses such as a database listening on HTTP at a specific port, API servers, static websites, etc. Basically we can turn NGINX into an HTTP router. NGINX is also a great front man for back-end services such as HTTPS and HTTP/2. For instance if you had a Database, API Server and static site you could have an SSL certificate just for NGINX and they would all be behind HTTPS and the reverse proxy would convert the HTTPS and send HTTP. That’s a post for another time however.
In this post I wanted to show how you can use NGINX and Apache CouchDB to make a reverse proxy such as:
This reverse proxy will take in all requests to NGINX under
/couch/ and forward them to
127.0.01:5984 where CouchDB typically lives serving on port 5984. Sufficient to say CouchDB is living under the
/couch HTTP route.
Let’s take a simple example for an NGINX configuration with CouchDB as a reverse proxy:
This works great but as a reverse proxy but I will say I’ve had problems in the past with Fauxton working as it needs to server off a root URL. In this case you can setup a subdomain as say
couch.lloydrochester.com. Note this needs a new A record in the DNS but will also serve Fauxton without any
Another nginx configuration file that serves CouchDB under the couch.lloydrochester.com subdomain.
Note: if you have these files in
sites-available be sure to have soft links to
sites-enabled, as well as restart NGINX.