couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Sphinx <>
Subject Re: Serving Simple HTML page to Public IP from CouchDB
Date Tue, 19 Mar 2013 13:15:21 GMT
Sure, here is a secret gist with the relevant files:

To state the problem again: I cannot access the webpage by hitting:

It will simply return the JSON welcome message. However, if I (or anyone else I assume) were
to create an entry in THEIR /etc/hosts file:		couch

And hit the url:


Then it works. That's great, but it's not what I want. I want the public IP to go directly
to the index.html file no matter what computer is hitting it. The only way I've found to get
this to occur is to put in [vhosts]:

The public IP. This DOES work, but it breaks the entire database. You can't write nor can
you retrieve any docs from the database. This makes sense to me because the database isn't
at the IP anymore, just the webpage.

A sysadmin friend of mine told me that this is why you need a vhost set up, but now it's beginning
to seem as if I actually want a "reverse proxy" which is functionality that is not provided
by CouchDB? Or is serving a couch app to the public IP possible with only Couch running on
the RPi? Thank you for the help so far, it is really appreciated.

On Mar 19, 2013, at 4:53 AM, Dave Cottlehuber <> wrote:

> Hi Chris,
> Sorry to hear you are stuck on this! I remember being equally
> mind-boggled a couple years back. It will "click" soon hopefully.
> BTW It will help a great deal if you can put a minimal case together &
> post it back to the list (or via a paste service gist friendpaste
> etc). vhosts, your CNAME, the design doc including the rewriter rules,
> and the specific error message in the logfile.
> I have this setup at home but power's off and I don't have the config
> handy, if I have a free spot today I'll whip an example up. So this is
> from memory,
> Ensure you've got:
> [httpd]
> bind_address =
> [vhosts]
> cname:5984 = /dbname/_design/ddoc_name/_rewrite
> in your local.ini, replacing cname, dbname, ddoc_name as appropriate.
> In your design document, your rewriter key should be something like this:
> [
>    {"from": "/","to": "/index.html"},
>    {"from": "/*","to": "/*" }
> ]
> And obviously there should be an attachment called index.html within the ddoc.
> Check through and
> see if that helps you out. I'm pretty sure out of this thread we can
> put a better example up!
> Note that you could also set http port to 80 both in the vhost and in
> local.ini under [httpd] section which would be even tidier.
> A+
> Dave

> On 19 March 2013 09:32, Chris Sphinx <> wrote:
>> I have a CouchDB running on a RPi behind a router. I've seen countless tutorials
about "pretty urls", but no matter what I do I just cannot get this to work for my public
IP. All I want to do is be able to serve a boring webpage to anyone that hits
>> But the only way I was able to do this is by putting the public IP under vhosts in
the local.ini file. Doing so breaks the database and I can't access it in any way until I
remove the line from the local.ini file and restart it. Trying to get at any part of the database
results in:
>> {"error":"not_found","reason":"Document is missing attachment"}
>> Sure, I can set up something like<tab>couch to hook up to http://couch:5984
on the RPi. I can even load it from another machine, but I have to set my /etc/hosts on whatever
machine I want to use to include<tab>couch. What if I want to allow anyone
to access the page without having to hack their /etc/hosts file? How am I supposed to set
this up?
>> I get the feeling that the only way to do this is to run something like ngix in front
of the database with a reverse proxy, but I'm already killing an ant with a sledgehammer and
I feel that there is just something I am overlooking here. Can anybody tell me what I'm doing
wrong? Or walk me through how to get CouchDB to serve up a webpage to a public IP?

View raw message