Differences between revisions 2 and 3
Revision 2 as of 2011-11-23 15:08:30
Size: 1463
Editor: 62
Comment: add ContributorGroup link
Revision 3 as of 2013-06-05 22:23:43
Size: 1587
Editor: 71
Comment: official docs link
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

See also the [[http://docs.couchdb.org/en/latest/configuring.html#virtual-hosts|official documentation]] for this topic.

We have a new wiki. The migration is not 100% complete. You can help out by moving pages across. This wiki will exist for as long as there are pages left.

The official documentation has moved to http://docs.couchdb.org — The transition is not 100% complete, but http://docs.couchdb.org should be seen as having the latest info. In some cases, the wiki still has some more or older info on certain topics inside CouchDB.

You need to be added to the ContributorsGroup to edit the wiki. But don't worry! Just email any Mailing List or grab us on IRC and let us know your user name.

See also the official documentation for this topic.

CouchDB, since 0.11.0, can map requests to different locations based on the Host header. This allows different virtual hosts on the same machine to map to different databases or design documents, etc. The most common use case is to map a virtual host to a Rewrite Handler, to provide full control over the application's URIs.

To add a virtual host, add a CNAME pointer to the DNS for your domain name. For development and testing, it is sufficient to add an entry in the hosts file (/etc/hosts on Unix-like operating systems) pointing to For example:

# Aliases for CouchDB vhosts, see /etc/couchdb/local.ini       sofa.couchdb

Test that this is working:

$ ping sofa.couchdb
PING sofa.couchdb ( 56(84) bytes of data.
64 bytes from localhost.localdomain ( icmp_req=1 ttl=64 time=0.025 ms
64 bytes from localhost.localdomain ( icmp_req=2 ttl=64 time=0.051 ms

Finally, add an entry to your Configuration File in the [vhosts] section:

sofa.couchdb:5984 = /sofa/_design/sofa/_rewrite

If your CouchDB is listening on the default HTTP port, or is sitting behind a proxy, then don't specify a port number in the vhost key.

With the above setup, a request to http://sofa.couchdb:5984/sweet-o will be mapped to

Virtual_Hosts (last edited 2013-06-05 22:23:43 by 71)