You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Chris Sphinx <ch...@gmail.com> on 2013/03/19 09:32:03 UTC

Serving Simple HTML page to Public IP from CouchDB

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

http://my.pub.lic.ip:5984

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 127.0.0.1<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 my.pub.lic.ip<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?

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Robert Newson <rn...@apache.org>.
vhosting is based on the HTTP 1.1 "Host" header.

I think Chris already said he tried vhosting using the ip address and
was locked out of basic functionality, which makes sense.

You could bind a separate ip address as benoit says. You wouldn't even
need two NIC's on most linuxes, you can do that wacky binding thing
iirc.

B.

On 20 March 2013 00:09, Benoit Chesneau <bc...@gmail.com> wrote:
> On Tue, Mar 19, 2013 at 5:01 PM, Miles Fidelman
> <mf...@meetinghouse.net> wrote:
>> I assume that CouchDB is doing NAME-based virtual hosting, which means it's
>
>> [vhosts]
>> 184.75.155.16:5984 = /test/_design/test/_rewrite
>>
> That could work if couchdb would be able to listen on multiple
> interfaces. If it's your main IP then make sure to start couchdb on
> 0.0.0.0 and access to the couchdb API using localhost. If not you
> won't be able anymore to use it. You can also use an alias to your
> main interface and bind it to an IP.
>
> - benoit

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Mar 19, 2013 at 5:01 PM, Miles Fidelman
<mf...@meetinghouse.net> wrote:
> I assume that CouchDB is doing NAME-based virtual hosting, which means it's

> [vhosts]
> 184.75.155.16:5984 = /test/_design/test/_rewrite
>
That could work if couchdb would be able to listen on multiple
interfaces. If it's your main IP then make sure to start couchdb on
0.0.0.0 and access to the couchdb API using localhost. If not you
won't be able anymore to use it. You can also use an alias to your
main interface and bind it to an IP.

- benoit

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Miles Fidelman <mf...@meetinghouse.net>.
I assume that CouchDB is doing NAME-based virtual hosting, which means 
it's doing its matching based on the URL in the HTTP header, not the IP 
address.

So, instead of
[vhosts]
couch:5984 = /test/_design/test/_rewrite

in your config file, you might want to try:

[vhosts]
184.75.155.16:5984 = /test/_design/test/_rewrite

And see what happens.

Now, if that's an IP address subject to change (say, if you're on a home 
router provided by a broadband supplier), you're going to have troubles 
every once in a while.

Re. your comment in another message:
> Okay, sorry about this I'm a programmer but I don't know anything about networking. I just want to be sure there's no way to achieve the functionality I'm talking about without 1) getting a domain name or 2) setting an entry in the /etc/hosts file on the computer I want to use to access the page. Is that right?

Not to be (too) snarky, but if you're going to be programming stuff that 
presents a network interface, you might consider learning something 
about networking.

Miles Fidelman



Chris Sphinx wrote:
> Sure, here is a secret gist with the relevant files:
>
> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
>
> To state the problem again: I cannot access the webpage by hitting:
>
> http://184.75.155.16:5984
>
> 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:
>
> 184.75.155.16		couch
>
> And hit the url:
>
> http://couch:5984
>
> 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]:
>
> 184.75.155.16:5984
>
> 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 <dc...@jsonified.com> 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 = 0.0.0.0
>>
>> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>>>
>>> http://my.pub.lic.ip:5984
>>>
>>> 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 127.0.0.1<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 my.pub.lic.ip<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?


-- 
In theory, there is no difference between theory and practice.
In practice, there is.   .... Yogi Berra


Re: Serving Simple HTML page to Public IP from CouchDB

Posted by mike <wi...@gmail.com>.
Sorry I am arriving late to this thread, and maybe this is not a
solution... but if you get a (free) dropbox.com account you go to
www.site44.com/ and create a new website from one of your dropbox
folders.  It will look like www.mydbfolder.site44.com.    (site44 is
also free).

hth

Mike B


On Tue, Mar 19, 2013 at 6:59 PM, Robert Newson <rn...@apache.org> wrote:
> The third alternative is setting up your own dns server (bind,
> dnsmasq, a million other options) and pointing to it from all your
> clients. In your situation that's just a slightly fancier variant of
> your 2).
>
> You could also try IrisCouch or Cloudant, I believe low levels of
> usage are free in both but do check. Disclaimer: I work for Cloudant.
>
> B.
>
> On 19 March 2013 22:52, Chris Sphinx <ch...@gmail.com> wrote:
>> Okay, sorry about this I'm a programmer but I don't know anything about networking. I just want to be sure there's no way to achieve the functionality I'm talking about without 1) getting a domain name or 2) setting an entry in the /etc/hosts file on the computer I want to use to access the page. Is that right?
>>
>>
>> On Mar 19, 2013, at 6:45 PM, Robert Newson <rn...@apache.org> wrote:
>>
>>> if you want a name maped to an ip address that works anywhere in the
>>> world, that's what DNS *is*. :)
>>>
>>> If you control all the clients, you can add local hosts files and/or
>>> point at your own dns server with your own custom zone.
>>>
>>> B.
>>>
>>> On 19 March 2013 22:40, Chris Sphinx <ch...@gmail.com> wrote:
>>>> I simply want to be able to access an html page from the public IP without breaking the Couch. This is just for my personal convenience, this is not for a public site. But I want to be able to access the webpage from anywhere (like a mobile device or public computer).
>>>>
>>>> If I understand correctly, I could make this work if I had a registered domain name? That's fine, but is there any way to accomplish this WITHOUT buying a domain name?
>>>>
>>>>
>>>> On Mar 19, 2013, at 9:22 AM, Robert Newson <rn...@apache.org> wrote:
>>>>
>>>>> Virtual Hosting is predicated on host names. Vhosting the ip address
>>>>> is not recommended, for the reasons you've already encountered.
>>>>>
>>>>> What are you trying to achieve? It's very odd to direct people to your
>>>>> site via IP address. Are you trying to use the virtual host feature as
>>>>> a security mechanism?
>>>>>
>>>>> B.
>>>>>
>>>>> On 19 March 2013 13:15, Chris Sphinx <ch...@gmail.com> wrote:
>>>>>> Sure, here is a secret gist with the relevant files:
>>>>>>
>>>>>> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
>>>>>>
>>>>>> To state the problem again: I cannot access the webpage by hitting:
>>>>>>
>>>>>> http://184.75.155.16:5984
>>>>>>
>>>>>> 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:
>>>>>>
>>>>>> 184.75.155.16           couch
>>>>>>
>>>>>> And hit the url:
>>>>>>
>>>>>> http://couch:5984
>>>>>>
>>>>>> 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]:
>>>>>>
>>>>>> 184.75.155.16:5984
>>>>>>
>>>>>> 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 <dc...@jsonified.com> 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 = 0.0.0.0
>>>>>>>
>>>>>>> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>>>>>>>>
>>>>>>>> http://my.pub.lic.ip:5984
>>>>>>>>
>>>>>>>> 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 127.0.0.1<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 my.pub.lic.ip<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?
>>>>>>>

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Robert Newson <rn...@apache.org>.
The third alternative is setting up your own dns server (bind,
dnsmasq, a million other options) and pointing to it from all your
clients. In your situation that's just a slightly fancier variant of
your 2).

You could also try IrisCouch or Cloudant, I believe low levels of
usage are free in both but do check. Disclaimer: I work for Cloudant.

B.

On 19 March 2013 22:52, Chris Sphinx <ch...@gmail.com> wrote:
> Okay, sorry about this I'm a programmer but I don't know anything about networking. I just want to be sure there's no way to achieve the functionality I'm talking about without 1) getting a domain name or 2) setting an entry in the /etc/hosts file on the computer I want to use to access the page. Is that right?
>
>
> On Mar 19, 2013, at 6:45 PM, Robert Newson <rn...@apache.org> wrote:
>
>> if you want a name maped to an ip address that works anywhere in the
>> world, that's what DNS *is*. :)
>>
>> If you control all the clients, you can add local hosts files and/or
>> point at your own dns server with your own custom zone.
>>
>> B.
>>
>> On 19 March 2013 22:40, Chris Sphinx <ch...@gmail.com> wrote:
>>> I simply want to be able to access an html page from the public IP without breaking the Couch. This is just for my personal convenience, this is not for a public site. But I want to be able to access the webpage from anywhere (like a mobile device or public computer).
>>>
>>> If I understand correctly, I could make this work if I had a registered domain name? That's fine, but is there any way to accomplish this WITHOUT buying a domain name?
>>>
>>>
>>> On Mar 19, 2013, at 9:22 AM, Robert Newson <rn...@apache.org> wrote:
>>>
>>>> Virtual Hosting is predicated on host names. Vhosting the ip address
>>>> is not recommended, for the reasons you've already encountered.
>>>>
>>>> What are you trying to achieve? It's very odd to direct people to your
>>>> site via IP address. Are you trying to use the virtual host feature as
>>>> a security mechanism?
>>>>
>>>> B.
>>>>
>>>> On 19 March 2013 13:15, Chris Sphinx <ch...@gmail.com> wrote:
>>>>> Sure, here is a secret gist with the relevant files:
>>>>>
>>>>> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
>>>>>
>>>>> To state the problem again: I cannot access the webpage by hitting:
>>>>>
>>>>> http://184.75.155.16:5984
>>>>>
>>>>> 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:
>>>>>
>>>>> 184.75.155.16           couch
>>>>>
>>>>> And hit the url:
>>>>>
>>>>> http://couch:5984
>>>>>
>>>>> 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]:
>>>>>
>>>>> 184.75.155.16:5984
>>>>>
>>>>> 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 <dc...@jsonified.com> 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 = 0.0.0.0
>>>>>>
>>>>>> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>>>>>>>
>>>>>>> http://my.pub.lic.ip:5984
>>>>>>>
>>>>>>> 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 127.0.0.1<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 my.pub.lic.ip<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?
>>>>>>

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Keith Gable <zi...@ignition-project.com>.
I'll also chime in: since CouchDB (and most other HTTP servers) expect to
use name-based virtual hosting (i.e. the HTTP Host: header), you will
probably want a hostname. You can figure out your public hostname by going
to, for example, http://www.showmemyip.com/. If you set this as the vhost
name, if you visit it, it'll show what you expect.

Or, if you want something memorable, you can sign up for DynDNS or No-IP,
both of which are free and give you a hostname pointing at your computer.
You just have to run their updater software (I prefer No-IP because I've
used them for a long time).

Note that if you have an internal network with private addresses and are
port forwarding, you'll run into some trouble. whatever.your-isp.net would
resolve to an Internet-routable address, but your TCP/IP socket needs to
talk to your internal address (192.168.x.x, 172.16.x.x, 10.x.x.x). If you
have control over the DNS server on your internal network, you could make
your DNS server return the internal IP address for your DynDNS/No-IP
hostname.

However, it's worth noting that you will run into this exact problem using
IP addresses: 184.75.155.16:5984 will not work to access your server
if 184.75.155.16 is a router that is port forwarding port 5984 to
192.168.0.1:5984 (with some exceptions: some routers are advanced and
intelligently reroute your packet to the proper destination).



---
Keith Gable
A+, Network+, and Storage+ Certified Professional
Apple Certified Technical Coordinator
Mobile Application Developer / Web Developer


On Tue, Mar 19, 2013 at 11:24 PM, Chris Sphinx <ch...@gmail.com>wrote:

> thanks everyone for all of the suggestions and help. It's really helped me
> learn more about how this all works

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Chris Sphinx <ch...@gmail.com>.
thanks everyone for all of the suggestions and help. It's really helped me learn more about how this all works

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Christian Tellnes <ch...@tellnes.no>.
Or if you want something more easy, take a look at http://xip.io

Christian

onsdag 20. mars 2013 skrev Andrew Melo følgende:

> On Tue, Mar 19, 2013 at 5:52 PM, Chris Sphinx <chrissphinx@gmail.com<javascript:;>>
> wrote:
> > Okay, sorry about this I'm a programmer but I don't know anything about
> networking. I just want to be sure there's no way to achieve the
> functionality I'm talking about without 1) getting a domain name or 2)
> setting an entry in the /etc/hosts file on the computer I want to use to
> access the page. Is that right?
>
> If you're not wanting a domain name for, I assume, cost reasons, have
> you looked at a product like dyndns.org that'll provide a free
> subdomain?
>
> -Andrew
>
> >
> >
> > On Mar 19, 2013, at 6:45 PM, Robert Newson <rn...@apache.org> wrote:
> >
> >> if you want a name maped to an ip address that works anywhere in the
> >> world, that's what DNS *is*. :)
> >>
> >> If you control all the clients, you can add local hosts files and/or
> >> point at your own dns server with your own custom zone.
> >>
> >> B.
> >>
> >> On 19 March 2013 22:40, Chris Sphinx <ch...@gmail.com> wrote:
> >>> I simply want to be able to access an html page from the public IP
> without breaking the Couch. This is just for my personal convenience, this
> is not for a public site. But I want to be able to access the webpage from
> anywhere (like a mobile device or public computer).
> >>>
> >>> If I understand correctly, I could make this work if I had a
> registered domain name? That's fine, but is there any way to accomplish
> this WITHOUT buying a domain name?
> >>>
> >>>
> >>> On Mar 19, 2013, at 9:22 AM, Robert Newson <rn...@apache.org> wrote:
> >>>
> >>>> Virtual Hosting is predicated on host names. Vhosting the ip address
> >>>> is not recommended, for the reasons you've already encountered.
> >>>>
> >>>> What are you trying to achieve? It's very odd to direct people to your
> >>>> site via IP address. Are you trying to use the virtual host feature as
> >>>> a security mechanism?
> >>>>
> >>>> B.
> >>>>
> >>>> On 19 March 2013 13:15, Chris Sphinx <ch...@gmail.com> wrote:
> >>>>> Sure, here is a secret gist with the relevant files:
> >>>>>
> >>>>> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
> >>>>>
> >>>>> To state the problem again: I cannot access the webpage by hitting:
> >>>>>
> >>>>> http://184.75.155.16:5984
> >>>>>
> >>>>> 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:
> >>>>>
> >>>>> 184.75.155.16           couch
> >>>>>
> >>>>> And hit the url:
> >>>>>
> >>>>> http://couch:5984
> >>>>>
> >>>>> 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]:
> >>>>>
> >>>>> 184.75.155.16:5984
> >>>>>
> >>>>> 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 <dc...@jsonified.com>
> 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 desi--
> --
> Andrew Melo
>


-- 
Sincerely, Christian Vaagland Tellnes
Phone: +4791861617
https://github.com/tellnes

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Andrew Melo <an...@gmail.com>.
On Tue, Mar 19, 2013 at 5:52 PM, Chris Sphinx <ch...@gmail.com> wrote:
> Okay, sorry about this I'm a programmer but I don't know anything about networking. I just want to be sure there's no way to achieve the functionality I'm talking about without 1) getting a domain name or 2) setting an entry in the /etc/hosts file on the computer I want to use to access the page. Is that right?

If you're not wanting a domain name for, I assume, cost reasons, have
you looked at a product like dyndns.org that'll provide a free
subdomain?

-Andrew

>
>
> On Mar 19, 2013, at 6:45 PM, Robert Newson <rn...@apache.org> wrote:
>
>> if you want a name maped to an ip address that works anywhere in the
>> world, that's what DNS *is*. :)
>>
>> If you control all the clients, you can add local hosts files and/or
>> point at your own dns server with your own custom zone.
>>
>> B.
>>
>> On 19 March 2013 22:40, Chris Sphinx <ch...@gmail.com> wrote:
>>> I simply want to be able to access an html page from the public IP without breaking the Couch. This is just for my personal convenience, this is not for a public site. But I want to be able to access the webpage from anywhere (like a mobile device or public computer).
>>>
>>> If I understand correctly, I could make this work if I had a registered domain name? That's fine, but is there any way to accomplish this WITHOUT buying a domain name?
>>>
>>>
>>> On Mar 19, 2013, at 9:22 AM, Robert Newson <rn...@apache.org> wrote:
>>>
>>>> Virtual Hosting is predicated on host names. Vhosting the ip address
>>>> is not recommended, for the reasons you've already encountered.
>>>>
>>>> What are you trying to achieve? It's very odd to direct people to your
>>>> site via IP address. Are you trying to use the virtual host feature as
>>>> a security mechanism?
>>>>
>>>> B.
>>>>
>>>> On 19 March 2013 13:15, Chris Sphinx <ch...@gmail.com> wrote:
>>>>> Sure, here is a secret gist with the relevant files:
>>>>>
>>>>> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
>>>>>
>>>>> To state the problem again: I cannot access the webpage by hitting:
>>>>>
>>>>> http://184.75.155.16:5984
>>>>>
>>>>> 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:
>>>>>
>>>>> 184.75.155.16           couch
>>>>>
>>>>> And hit the url:
>>>>>
>>>>> http://couch:5984
>>>>>
>>>>> 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]:
>>>>>
>>>>> 184.75.155.16:5984
>>>>>
>>>>> 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 <dc...@jsonified.com> 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 = 0.0.0.0
>>>>>>
>>>>>> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>>>>>>>
>>>>>>> http://my.pub.lic.ip:5984
>>>>>>>
>>>>>>> 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 127.0.0.1<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 my.pub.lic.ip<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?
>>>>>>



-- 
--
Andrew Melo

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Chris Sphinx <ch...@gmail.com>.
Okay, sorry about this I'm a programmer but I don't know anything about networking. I just want to be sure there's no way to achieve the functionality I'm talking about without 1) getting a domain name or 2) setting an entry in the /etc/hosts file on the computer I want to use to access the page. Is that right?


On Mar 19, 2013, at 6:45 PM, Robert Newson <rn...@apache.org> wrote:

> if you want a name maped to an ip address that works anywhere in the
> world, that's what DNS *is*. :)
> 
> If you control all the clients, you can add local hosts files and/or
> point at your own dns server with your own custom zone.
> 
> B.
> 
> On 19 March 2013 22:40, Chris Sphinx <ch...@gmail.com> wrote:
>> I simply want to be able to access an html page from the public IP without breaking the Couch. This is just for my personal convenience, this is not for a public site. But I want to be able to access the webpage from anywhere (like a mobile device or public computer).
>> 
>> If I understand correctly, I could make this work if I had a registered domain name? That's fine, but is there any way to accomplish this WITHOUT buying a domain name?
>> 
>> 
>> On Mar 19, 2013, at 9:22 AM, Robert Newson <rn...@apache.org> wrote:
>> 
>>> Virtual Hosting is predicated on host names. Vhosting the ip address
>>> is not recommended, for the reasons you've already encountered.
>>> 
>>> What are you trying to achieve? It's very odd to direct people to your
>>> site via IP address. Are you trying to use the virtual host feature as
>>> a security mechanism?
>>> 
>>> B.
>>> 
>>> On 19 March 2013 13:15, Chris Sphinx <ch...@gmail.com> wrote:
>>>> Sure, here is a secret gist with the relevant files:
>>>> 
>>>> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
>>>> 
>>>> To state the problem again: I cannot access the webpage by hitting:
>>>> 
>>>> http://184.75.155.16:5984
>>>> 
>>>> 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:
>>>> 
>>>> 184.75.155.16           couch
>>>> 
>>>> And hit the url:
>>>> 
>>>> http://couch:5984
>>>> 
>>>> 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]:
>>>> 
>>>> 184.75.155.16:5984
>>>> 
>>>> 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 <dc...@jsonified.com> 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 = 0.0.0.0
>>>>> 
>>>>> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>>>>>> 
>>>>>> http://my.pub.lic.ip:5984
>>>>>> 
>>>>>> 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 127.0.0.1<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 my.pub.lic.ip<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?
>>>>> 

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Robert Newson <rn...@apache.org>.
if you want a name maped to an ip address that works anywhere in the
world, that's what DNS *is*. :)

If you control all the clients, you can add local hosts files and/or
point at your own dns server with your own custom zone.

B.

On 19 March 2013 22:40, Chris Sphinx <ch...@gmail.com> wrote:
> I simply want to be able to access an html page from the public IP without breaking the Couch. This is just for my personal convenience, this is not for a public site. But I want to be able to access the webpage from anywhere (like a mobile device or public computer).
>
> If I understand correctly, I could make this work if I had a registered domain name? That's fine, but is there any way to accomplish this WITHOUT buying a domain name?
>
>
> On Mar 19, 2013, at 9:22 AM, Robert Newson <rn...@apache.org> wrote:
>
>> Virtual Hosting is predicated on host names. Vhosting the ip address
>> is not recommended, for the reasons you've already encountered.
>>
>> What are you trying to achieve? It's very odd to direct people to your
>> site via IP address. Are you trying to use the virtual host feature as
>> a security mechanism?
>>
>> B.
>>
>> On 19 March 2013 13:15, Chris Sphinx <ch...@gmail.com> wrote:
>>> Sure, here is a secret gist with the relevant files:
>>>
>>> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
>>>
>>> To state the problem again: I cannot access the webpage by hitting:
>>>
>>> http://184.75.155.16:5984
>>>
>>> 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:
>>>
>>> 184.75.155.16           couch
>>>
>>> And hit the url:
>>>
>>> http://couch:5984
>>>
>>> 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]:
>>>
>>> 184.75.155.16:5984
>>>
>>> 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 <dc...@jsonified.com> 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 = 0.0.0.0
>>>>
>>>> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>>>>>
>>>>> http://my.pub.lic.ip:5984
>>>>>
>>>>> 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 127.0.0.1<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 my.pub.lic.ip<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?
>>>>

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Chris Sphinx <ch...@gmail.com>.
I simply want to be able to access an html page from the public IP without breaking the Couch. This is just for my personal convenience, this is not for a public site. But I want to be able to access the webpage from anywhere (like a mobile device or public computer).

If I understand correctly, I could make this work if I had a registered domain name? That's fine, but is there any way to accomplish this WITHOUT buying a domain name?


On Mar 19, 2013, at 9:22 AM, Robert Newson <rn...@apache.org> wrote:

> Virtual Hosting is predicated on host names. Vhosting the ip address
> is not recommended, for the reasons you've already encountered.
> 
> What are you trying to achieve? It's very odd to direct people to your
> site via IP address. Are you trying to use the virtual host feature as
> a security mechanism?
> 
> B.
> 
> On 19 March 2013 13:15, Chris Sphinx <ch...@gmail.com> wrote:
>> Sure, here is a secret gist with the relevant files:
>> 
>> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
>> 
>> To state the problem again: I cannot access the webpage by hitting:
>> 
>> http://184.75.155.16:5984
>> 
>> 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:
>> 
>> 184.75.155.16           couch
>> 
>> And hit the url:
>> 
>> http://couch:5984
>> 
>> 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]:
>> 
>> 184.75.155.16:5984
>> 
>> 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 <dc...@jsonified.com> 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 = 0.0.0.0
>>> 
>>> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>>>> 
>>>> http://my.pub.lic.ip:5984
>>>> 
>>>> 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 127.0.0.1<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 my.pub.lic.ip<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?
>>> 

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Robert Newson <rn...@apache.org>.
Virtual Hosting is predicated on host names. Vhosting the ip address
is not recommended, for the reasons you've already encountered.

What are you trying to achieve? It's very odd to direct people to your
site via IP address. Are you trying to use the virtual host feature as
a security mechanism?

B.

On 19 March 2013 13:15, Chris Sphinx <ch...@gmail.com> wrote:
> Sure, here is a secret gist with the relevant files:
>
> https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c
>
> To state the problem again: I cannot access the webpage by hitting:
>
> http://184.75.155.16:5984
>
> 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:
>
> 184.75.155.16           couch
>
> And hit the url:
>
> http://couch:5984
>
> 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]:
>
> 184.75.155.16:5984
>
> 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 <dc...@jsonified.com> 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 = 0.0.0.0
>>
>> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>>>
>>> http://my.pub.lic.ip:5984
>>>
>>> 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 127.0.0.1<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 my.pub.lic.ip<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?
>>

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Chris Sphinx <ch...@gmail.com>.
Sure, here is a secret gist with the relevant files:

https://gist.github.com/chrissphinx/a9e8411fa6efefa9572c

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

http://184.75.155.16:5984

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:

184.75.155.16		couch

And hit the url:

http://couch:5984

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]:

184.75.155.16:5984

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 <dc...@jsonified.com> 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 = 0.0.0.0
> 
> [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 http://docs.couchdb.org/en/latest/pretty_urls.html 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 <ch...@gmail.com> 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
>> 
>> http://my.pub.lic.ip:5984
>> 
>> 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 127.0.0.1<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 my.pub.lic.ip<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?
> 

Re: Serving Simple HTML page to Public IP from CouchDB

Posted by Dave Cottlehuber <dc...@jsonified.com>.
On 19 March 2013 09:32, Chris Sphinx <ch...@gmail.com> 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
>
> http://my.pub.lic.ip:5984
>
> 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 127.0.0.1<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 my.pub.lic.ip<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?

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 = 0.0.0.0

[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 http://docs.couchdb.org/en/latest/pretty_urls.html 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