You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Alexander Gabriel <al...@barbalex.ch> on 2014/03/03 11:58:02 UTC

getting rewrite to work (ignore last mail, was malformed...)

Hi couchers

Linux- and networking-noob here.

I'm having a hard time trying to get rewrites to work.

My goal is this:
User goes to http://artdaten.ch
User gets forwarded to http://artdaten.ch/artendb/_design/artendb/index.html

or better: index.html opens at http://artdaten.ch/index.html

What I've done:

to forward from port 80 to port 5984:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 5984

in etc/couchdb/local.ini:
port = 5984
bind_address = 0.0.0.0
in [vhost] section: artdaten.ch:5984 = /artendb/_design/artendb/_rewrite
service couchdb restart

in rewrites.json:
[
{
"from": "",
"to": "index.html"
}
]

This works. Well, sort of: index.html opens at http://artdaten.ch/index.html.
But now lots of paths aren't found, so no functionality nor stying.
So I added some rules to rewrites.json:

[
{
"from": "",
"to": "index.html"
},
{
"from": "favicon.ico",
"to": "favicon.ico"
},
{
"from": "style/*",
"to": "style/*"
},
{
"from": "images/*",
"to": "images/*"
},
{
"from": "vendor/*",
"to": "vendor/*"
},
{
"from": "fonts/*",
"to": "fonts/*"
},
{
"from": "_view/*",
"to": "_view/*"
},
{
"from": "_list/*",
"to": "_list/*"
},
{
"from": "_updates/*",
"to": "_updates/*"
}
]

The files in style, images, vendor and fonts are now found. But views and
lists aren't.

Plus pushing the couchapp with the traditional python-tool doesn't work any
more. I have to comment out "artdaten.ch:5984 =
/artendb/_design/artendb/_rewrite" in the vhost section of local.ini to
push, reinstate vhost, then restart couchdb. Very pesky.

(Plus somehow when changing rewrite rules and local.ini repeatedly I have
managed to be completely refused ssh-access by my virtual server twice
now...)

Can you help?

Alex

Re: getting rewrite to work (ignore last mail, was malformed...)

Posted by Alexander Gabriel <al...@barbalex.ch>.
got it once more:

Instead of
couchapp push artendb http://user:password@arteigenschaften.ch/artendb

I do:
couchapp push artendb http://user:password@arteigenschaften.ch

hm. I did mention that I'm a linux and netwok noob at the beginning of this
monologue, didn't I?
I had spent MANY hours on this problem before.

Sorry for bugging you guys!

Alex



2014-03-03 21:57 GMT+01:00 Alexander Gabriel <al...@barbalex.ch>:

> got it!
>
> I added another line to the vhosts section of local.ini:
> artdaten.ch = /artendb/_design/artendb/rewrite
>
> Does any on know how to enable pushing data with the traditional python
> couchapp tool without having to turn off vhosts beforehand?
>
> I'm doing this: couchapp push artendb
> http://user:password@artdaten.ch:5984/artendb
>
> and getting this error: not found, reason: missing
>
> Alex
>
>
>
> 2014-03-03 21:49 GMT+01:00 Alexander Gabriel <al...@barbalex.ch>:
>
> I finally found an answer from J. Chris Anderson to someone elses question
>> in 2011:
>>
>> "You need a rewrite directive that passes through all requests to the
>> database name, to the raw database api. It needs to be the last one in the
>> rewrites.json, and should look like this:"
>> https://github.com/couchbaselabs/pages/blob/master/rewrites.json#L54<https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fcouchbaselabs%2Fpages%2Fblob%2Fmaster%2Frewrites.json%23L54&sa=D&sntz=1&usg=AFQjCNFP7KwkggHP_4fr4klRJ5mVevACyg>
>>
>> So I added this rule as last to rewrites.json:
>> {
>> "from" : "artendb/*",
>>  "to" : "../../*"
>> }
>>
>> And: Yes, views and lists work!
>>
>> I also added
>> {
>> "from": "index.html",
>>  "to": "index.html"
>> }
>> for reloading index.html.
>>
>> BUT: This all works IF port 5984 is used.
>>
>> I want people to be able to access the site using http://artdaten.chthough. Not:
>> http://artdaten.ch:5984.
>>
>> Somehow redirecting like this:
>> sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT
>> --to-ports 5984
>> doesn't seem to work any more.
>>
>> How can I get things to work with port 80?
>>
>> Alex
>>
>> 2014-03-03 11:58 GMT+01:00 Alexander Gabriel <al...@barbalex.ch>:
>>
>>  Hi couchers
>>>
>>> Linux- and networking-noob here.
>>>
>>> I'm having a hard time trying to get rewrites to work.
>>>
>>> My goal is this:
>>> User goes to http://artdaten.ch
>>> User gets forwarded to
>>> http://artdaten.ch/artendb/_design/artendb/index.html
>>> or better: index.html opens at http://artdaten.ch/index.html
>>>
>>> What I've done:
>>>
>>> to forward from port 80 to port 5984:
>>> iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports
>>> 5984
>>>
>>> in etc/couchdb/local.ini:
>>> port = 5984
>>> bind_address = 0.0.0.0
>>> in [vhost] section: artdaten.ch:5984 = /artendb/_design/artendb/_rewrite
>>> service couchdb restart
>>>
>>> in rewrites.json:
>>> [
>>> {
>>> "from": "",
>>>  "to": "index.html"
>>> }
>>> ]
>>>
>>> This works. Well, sort of: index.html opens at
>>> http://artdaten.ch/index.html. But now lots of paths aren't found, so
>>> no functionality nor stying.
>>> So I added some rules to rewrites.json:
>>>
>>> [
>>> {
>>> "from": "",
>>>  "to": "index.html"
>>> },
>>> {
>>> "from": "favicon.ico",
>>>  "to": "favicon.ico"
>>> },
>>> {
>>> "from": "style/*",
>>>  "to": "style/*"
>>> },
>>> {
>>> "from": "images/*",
>>>  "to": "images/*"
>>> },
>>> {
>>> "from": "vendor/*",
>>>  "to": "vendor/*"
>>> },
>>> {
>>> "from": "fonts/*",
>>>  "to": "fonts/*"
>>> },
>>> {
>>> "from": "_view/*",
>>>  "to": "_view/*"
>>> },
>>> {
>>> "from": "_list/*",
>>>  "to": "_list/*"
>>> },
>>> {
>>> "from": "_updates/*",
>>>  "to": "_updates/*"
>>> }
>>> ]
>>>
>>> The files in style, images, vendor and fonts are now found. But views
>>> and lists aren't.
>>>
>>> Plus pushing the couchapp with the traditional python-tool doesn't work
>>> any more. I have to comment out "artdaten.ch:5984 =
>>> /artendb/_design/artendb/_rewrite" in the vhost section of local.ini to
>>> push, reinstate vhost, then restart couchdb. Very pesky.
>>>
>>> (Plus somehow when changing rewrite rules and local.ini repeatedly I
>>> have managed to be completely refused ssh-access by my virtual server twice
>>> now...)
>>>
>>> Can you help?
>>>
>>> Alex
>>>
>>
>>
>

Re: getting rewrite to work (ignore last mail, was malformed...)

Posted by Alexander Gabriel <al...@barbalex.ch>.
got it!

I added another line to the vhosts section of local.ini:
artdaten.ch = /artendb/_design/artendb/rewrite

Does any on know how to enable pushing data with the traditional python
couchapp tool without having to turn off vhosts beforehand?

I'm doing this: couchapp push artendb
http://user:password@artdaten.ch:5984/artendb

and getting this error: not found, reason: missing

Alex



2014-03-03 21:49 GMT+01:00 Alexander Gabriel <al...@barbalex.ch>:

> I finally found an answer from J. Chris Anderson to someone elses question
> in 2011:
>
> "You need a rewrite directive that passes through all requests to the
> database name, to the raw database api. It needs to be the last one in the
> rewrites.json, and should look like this:"
> https://github.com/couchbaselabs/pages/blob/master/rewrites.json#L54<https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fcouchbaselabs%2Fpages%2Fblob%2Fmaster%2Frewrites.json%23L54&sa=D&sntz=1&usg=AFQjCNFP7KwkggHP_4fr4klRJ5mVevACyg>
>
> So I added this rule as last to rewrites.json:
> {
> "from" : "artendb/*",
>  "to" : "../../*"
> }
>
> And: Yes, views and lists work!
>
> I also added
> {
> "from": "index.html",
>  "to": "index.html"
> }
> for reloading index.html.
>
> BUT: This all works IF port 5984 is used.
>
> I want people to be able to access the site using http://artdaten.chthough. Not:
> http://artdaten.ch:5984.
>
> Somehow redirecting like this:
> sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT
> --to-ports 5984
> doesn't seem to work any more.
>
> How can I get things to work with port 80?
>
> Alex
>
> 2014-03-03 11:58 GMT+01:00 Alexander Gabriel <al...@barbalex.ch>:
>
>  Hi couchers
>>
>> Linux- and networking-noob here.
>>
>> I'm having a hard time trying to get rewrites to work.
>>
>> My goal is this:
>> User goes to http://artdaten.ch
>> User gets forwarded to
>> http://artdaten.ch/artendb/_design/artendb/index.html
>> or better: index.html opens at http://artdaten.ch/index.html
>>
>> What I've done:
>>
>> to forward from port 80 to port 5984:
>> iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports
>> 5984
>>
>> in etc/couchdb/local.ini:
>> port = 5984
>> bind_address = 0.0.0.0
>> in [vhost] section: artdaten.ch:5984 = /artendb/_design/artendb/_rewrite
>> service couchdb restart
>>
>> in rewrites.json:
>> [
>> {
>> "from": "",
>>  "to": "index.html"
>> }
>> ]
>>
>> This works. Well, sort of: index.html opens at
>> http://artdaten.ch/index.html. But now lots of paths aren't found, so no
>> functionality nor stying.
>> So I added some rules to rewrites.json:
>>
>> [
>> {
>> "from": "",
>>  "to": "index.html"
>> },
>> {
>> "from": "favicon.ico",
>>  "to": "favicon.ico"
>> },
>> {
>> "from": "style/*",
>>  "to": "style/*"
>> },
>> {
>> "from": "images/*",
>>  "to": "images/*"
>> },
>> {
>> "from": "vendor/*",
>>  "to": "vendor/*"
>> },
>> {
>> "from": "fonts/*",
>>  "to": "fonts/*"
>> },
>> {
>> "from": "_view/*",
>>  "to": "_view/*"
>> },
>> {
>> "from": "_list/*",
>>  "to": "_list/*"
>> },
>> {
>> "from": "_updates/*",
>>  "to": "_updates/*"
>> }
>> ]
>>
>> The files in style, images, vendor and fonts are now found. But views and
>> lists aren't.
>>
>> Plus pushing the couchapp with the traditional python-tool doesn't work
>> any more. I have to comment out "artdaten.ch:5984 =
>> /artendb/_design/artendb/_rewrite" in the vhost section of local.ini to
>> push, reinstate vhost, then restart couchdb. Very pesky.
>>
>> (Plus somehow when changing rewrite rules and local.ini repeatedly I have
>> managed to be completely refused ssh-access by my virtual server twice
>> now...)
>>
>> Can you help?
>>
>> Alex
>>
>
>

Re: getting rewrite to work (ignore last mail, was malformed...)

Posted by Alexander Gabriel <al...@barbalex.ch>.
I finally found an answer from J. Chris Anderson to someone elses question
in 2011:

"You need a rewrite directive that passes through all requests to the
database name, to the raw database api. It needs to be the last one in the
rewrites.json, and should look like this:"
https://github.com/couchbaselabs/pages/blob/master/rewrites.json#L54<https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fcouchbaselabs%2Fpages%2Fblob%2Fmaster%2Frewrites.json%23L54&sa=D&sntz=1&usg=AFQjCNFP7KwkggHP_4fr4klRJ5mVevACyg>

So I added this rule as last to rewrites.json:
{
"from" : "artendb/*",
"to" : "../../*"
}

And: Yes, views and lists work!

I also added
{
"from": "index.html",
"to": "index.html"
}
for reloading index.html.

BUT: This all works IF port 5984 is used.

I want people to be able to access the site using
http://artdaten.chthough. Not:
http://artdaten.ch:5984.

Somehow redirecting like this:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports
5984
doesn't seem to work any more.

How can I get things to work with port 80?

Alex

2014-03-03 11:58 GMT+01:00 Alexander Gabriel <al...@barbalex.ch>:

> Hi couchers
>
> Linux- and networking-noob here.
>
> I'm having a hard time trying to get rewrites to work.
>
> My goal is this:
> User goes to http://artdaten.ch
> User gets forwarded to
> http://artdaten.ch/artendb/_design/artendb/index.html
> or better: index.html opens at http://artdaten.ch/index.html
>
> What I've done:
>
> to forward from port 80 to port 5984:
> iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 5984
>
> in etc/couchdb/local.ini:
> port = 5984
> bind_address = 0.0.0.0
> in [vhost] section: artdaten.ch:5984 = /artendb/_design/artendb/_rewrite
> service couchdb restart
>
> in rewrites.json:
> [
> {
> "from": "",
>  "to": "index.html"
> }
> ]
>
> This works. Well, sort of: index.html opens at
> http://artdaten.ch/index.html. But now lots of paths aren't found, so no
> functionality nor stying.
> So I added some rules to rewrites.json:
>
> [
> {
> "from": "",
>  "to": "index.html"
> },
> {
> "from": "favicon.ico",
>  "to": "favicon.ico"
> },
> {
> "from": "style/*",
>  "to": "style/*"
> },
> {
> "from": "images/*",
>  "to": "images/*"
> },
> {
> "from": "vendor/*",
>  "to": "vendor/*"
> },
> {
> "from": "fonts/*",
>  "to": "fonts/*"
> },
> {
> "from": "_view/*",
>  "to": "_view/*"
> },
> {
> "from": "_list/*",
>  "to": "_list/*"
> },
> {
> "from": "_updates/*",
>  "to": "_updates/*"
> }
> ]
>
> The files in style, images, vendor and fonts are now found. But views and
> lists aren't.
>
> Plus pushing the couchapp with the traditional python-tool doesn't work
> any more. I have to comment out "artdaten.ch:5984 =
> /artendb/_design/artendb/_rewrite" in the vhost section of local.ini to
> push, reinstate vhost, then restart couchdb. Very pesky.
>
> (Plus somehow when changing rewrite rules and local.ini repeatedly I have
> managed to be completely refused ssh-access by my virtual server twice
> now...)
>
> Can you help?
>
> Alex
>