Configuring nginx + couchdb to deploy a couchapp as a public facing website.

Created: by Pradeep Gowda Updated: Jul 06, 2023 Tagged: couchdb · nginx

Three things to remember while configuring a couchapp to run as a web facing application. Below, I document the steps I took to deploy the example pages app from couchapp.org.

  1. set the vhost in /etc/couchdb/local.ini.
    [vhosts]
    home.btbytes.com = /pages/_design/pages/_rewrite
  1. add vhosts entry to couchdb by visiting configuration page in futon app and adding a new section:
    section = vhosts
    option = home.btbytes.com
    value = /pages/_design/pages/_rewrite
  1. configure nginx to proxy the requests to / to the port running couchdb. See ref
    location / {
        proxy_pass http://localhost:5984;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

Securing the web app with SSL.

Primary reference for securing the above installation with SSL certificates is :

I followed the instructions verbatim with success.

Tests

Use curl client to access https + basic_auth enabled site.

curl https://user:password@home.btbytes.com/page/index --cacert \
/etc/ssl/certs/home.btbytes.com.crt

This returns the page contents as expected.