You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by wh...@aol.com on 2010/08/20 00:41:04 UTC

reverse proxy discouraged?

Is using a reverse proxy to serve up html and couchdb from the same domain and port problematic?
Someone told me that it is highly discouraged 

and that html pages should be served from couchdb.
But on a site that is web 2.0 and has a complicated GUI there would need to be 100's of attachments that would be necessary to correctly
serve up a page as an attachment to a document.

This sounds unreasonable for development where 100's of changes are made per day.

The reverse proxy method seems feasible but why would it be discouraged?

Thanks,

Dan




 



Re: reverse proxy discouraged?

Posted by wh...@aol.com.
What about these scenarios:

1. I have a web 2.0 GUI based application where a user can create some content by pushing buttons and writing snippets of code -- the end result is stored as text -- and then saved to the database.
2. I want the user to be able to list their files, edit them, then resave them -- all from the web 2.0 interface.

or

1.  I have a web 2.0 application where users input the vitamins levels they take vs their symptom levels for each day. Each day
they can input their own symptom descriptions and values like 1 to 10.
2. When prompted,  the system grabs all their data and runs statistics on it in javascript.

In each case I want to do authentication -- like login/session/signup.
That kind of thing.

The web 2.0 GUI interfaces for both these projects involve
1000's of lines of javascript from different libraries, and multiple graphic image sets for the GUI, all of which are changing all the time
during the development process. 

How is couchdb used in these scenarios. Right now I'm trying to get it working with couch.js but running into the cross domain problem.  I can't send anything from an html page into the :5984 port.

Thanks,

Dan


 


 

 

-----Original Message-----
From: Randall Leeds <ra...@gmail.com>
To: user@couchdb.apache.org
Sent: Thu, Aug 19, 2010 4:42 pm
Subject: Re: reverse proxy discouraged?


I think for your use case a reverse proxy is fine, especially if the

'web2.0' content is a server itself running

python/ruby/perl/java/erlang/scala/node/insert/favorite/middleware/here

At which point you likely don't even need to expose couch to the

outside at all. Just put it in your private network and access it from

your application server.



Exposing couch directly to the world via a reverse proxy is probably

only a good plan if you need to co-host a public couch with other apps

or static files behind different virtual hosts or if you want to do

complicated authentication in front of your couch that couchdb can't

do itself.



-Randall



On Thu, Aug 19, 2010 at 15:41,  <wh...@aol.com> wrote:

> Is using a reverse proxy to serve up html and couchdb from the same domain and 

port problematic?

> Someone told me that it is highly discouraged

>

> and that html pages should be served from couchdb.

> But on a site that is web 2.0 and has a complicated GUI there would need to be 

100's of attachments that would be necessary to correctly

> serve up a page as an attachment to a document.

>

> This sounds unreasonable for development where 100's of changes are made per 

day.

>

> The reverse proxy method seems feasible but why would it be discouraged?

>

> Thanks,

>

> Dan

>

>

>

>

>

>

>

>


 

Re: reverse proxy discouraged?

Posted by Randall Leeds <ra...@gmail.com>.
On Thu, Aug 19, 2010 at 16:42, Randall Leeds <ra...@gmail.com> wrote:
> Exposing couch directly to the world via a reverse proxy is probably
> only a good plan if you need to co-host a public couch with other apps
> or static files behind different virtual hosts or if you want to do
> complicated authentication in front of your couch that couchdb can't
> do itself.

Otherwise, just expose the raw couchdb without the proxy.

Re: reverse proxy discouraged?

Posted by Randall Leeds <ra...@gmail.com>.
I think for your use case a reverse proxy is fine, especially if the
'web2.0' content is a server itself running
python/ruby/perl/java/erlang/scala/node/insert/favorite/middleware/here
At which point you likely don't even need to expose couch to the
outside at all. Just put it in your private network and access it from
your application server.

Exposing couch directly to the world via a reverse proxy is probably
only a good plan if you need to co-host a public couch with other apps
or static files behind different virtual hosts or if you want to do
complicated authentication in front of your couch that couchdb can't
do itself.

-Randall

On Thu, Aug 19, 2010 at 15:41,  <wh...@aol.com> wrote:
> Is using a reverse proxy to serve up html and couchdb from the same domain and port problematic?
> Someone told me that it is highly discouraged
>
> and that html pages should be served from couchdb.
> But on a site that is web 2.0 and has a complicated GUI there would need to be 100's of attachments that would be necessary to correctly
> serve up a page as an attachment to a document.
>
> This sounds unreasonable for development where 100's of changes are made per day.
>
> The reverse proxy method seems feasible but why would it be discouraged?
>
> Thanks,
>
> Dan
>
>
>
>
>
>
>
>

Re: reverse proxy discouraged?

Posted by Tyler Gillies <ty...@pdxbrain.com>.
if you have access to apache config, don't use .htaccess

from apache website:

"In general, you should never use .htaccess files unless you don't have
access to the main server configuration file. There is, for example, a
common misconception that user authentication should always be done in
.htaccess files, and, in more recent years, another miscomception that
mod_rewrite <http://httpd.apache.org/docs/trunk/mod/mod_rewrite.html>
directives
must go in.htaccess files. This is simply not the case. You can put user
authentication configurations in the main server configuration, and this is,
in fact, the preferred way to do things. Likewise, mod_rewrite directives
work better, in many respects, in the main server configuration."

On Fri, Aug 20, 2010 at 1:09 AM, Dennis Geurts <de...@luminis.eu>wrote:

> A possible solution might be as simple as this:
>
> create a virtualhost in apache2 that points to a particular documentRoot:
>
> file: /etc/apache2/sites-available/couchdb.example.com
> -start------
> <VirtualHost *:80>
>   ServerName couchdb.example.com
>   ServerAdmin user@example.com
>
>        DirectoryIndex index.html
>        DocumentRoot /var/www/couchdb.example.com/htdocs/
>        #Options FollowSymLinks
>        #AllowOverride None
> </VirtualHost>
> -end------
>
> sudo a2ensite couchdb.example.com
> sudo /etc/init.d/apache2 reload (or the equivalent for your system)
>
> then, in /var/www/couchdb.example.com/htdocs/
>
> create a file called '.htaccess'
> with the following content:
>
> -start------
> <Files .htaccess>
> order allow,deny
> deny from all
> </Files>
>
>
> <IfModule mod_rewrite.c>
>
> RewriteEngine on
>
> #the get options
> RewriteRule ^db-name(.*)$ http://localhost:5984/db-name$1 [P]
>
> </IfModule>
> -end------
>
> 'curl http://couchdb.example.com/index.html' will load the document
> residing at: /var/www/couchdb.example.com/htdocs/index.html
> 'curl http://couchdb.example.com/db-name' will load the document residing
> at: http://localhost:5984/db-name (i.e. access the couchdb database)
>
> make sure you have mod_proxy and mod_rewrite enabled!
>
>
> hope this helps,
>
> Dennis
>
>
>
> On 20 aug 2010, at 08:07, Randall Leeds wrote:
>
> > Ahh. I understand your problem.
> > Your html cannot reference :5984, for cross-domain rules (as you
> > noted), but instead the path you've forwarded to Couch.
> > I'm not an apache wizard. I won't even pretend to try to tell you how.
> > But if the example on the wiki and the apache docs is not enough,
> > hopefully someone can chime in here or maybe you can find someone on
> > IRC if you catch them at the right time.
> >
> > Asking in a more apache-specific forum might also yield some help.
> > Even if they're not familiar with Couch I assume anyone with
> > sufficient knowledge of the apache web server should be able to direct
> > you to how to get X-domain between virtual hosts, if indeed it's
> > virtual hosts that are the key.
> >
> > Good luck, Dan! And please, when you find out what you were missing
> > please tell everyone here and update the wiki with any useful info. I
> > have a feeling you're not the first nor the last person to try to set
> > this up.
> >
> > Cheers,
> > Randall
>
>


-- 
PdxBrain <http://www.pdxbrain.com> - I provide Elegant Web Hosting and
Domain Registration! <http://hosting.pdxbrain.com>

Ask me anything <http://tumble.pdxbrain.com/ask>!

Re: reverse proxy discouraged?

Posted by Dennis Geurts <de...@luminis.eu>.
A possible solution might be as simple as this:

create a virtualhost in apache2 that points to a particular documentRoot:

file: /etc/apache2/sites-available/couchdb.example.com
-start------
<VirtualHost *:80>
   ServerName couchdb.example.com
   ServerAdmin user@example.com

	DirectoryIndex index.html
        DocumentRoot /var/www/couchdb.example.com/htdocs/
	#Options FollowSymLinks
	#AllowOverride None
</VirtualHost>
-end------

sudo a2ensite couchdb.example.com
sudo /etc/init.d/apache2 reload (or the equivalent for your system)

then, in /var/www/couchdb.example.com/htdocs/

create a file called '.htaccess'
with the following content:

-start------
<Files .htaccess>
order allow,deny
deny from all
</Files>


<IfModule mod_rewrite.c>

RewriteEngine on

#the get options
RewriteRule ^db-name(.*)$ http://localhost:5984/db-name$1 [P]

</IfModule>
-end------

'curl http://couchdb.example.com/index.html' will load the document residing at: /var/www/couchdb.example.com/htdocs/index.html
'curl http://couchdb.example.com/db-name' will load the document residing at: http://localhost:5984/db-name (i.e. access the couchdb database)

make sure you have mod_proxy and mod_rewrite enabled!


hope this helps,

Dennis



On 20 aug 2010, at 08:07, Randall Leeds wrote:

> Ahh. I understand your problem.
> Your html cannot reference :5984, for cross-domain rules (as you
> noted), but instead the path you've forwarded to Couch.
> I'm not an apache wizard. I won't even pretend to try to tell you how.
> But if the example on the wiki and the apache docs is not enough,
> hopefully someone can chime in here or maybe you can find someone on
> IRC if you catch them at the right time.
> 
> Asking in a more apache-specific forum might also yield some help.
> Even if they're not familiar with Couch I assume anyone with
> sufficient knowledge of the apache web server should be able to direct
> you to how to get X-domain between virtual hosts, if indeed it's
> virtual hosts that are the key.
> 
> Good luck, Dan! And please, when you find out what you were missing
> please tell everyone here and update the wiki with any useful info. I
> have a feeling you're not the first nor the last person to try to set
> this up.
> 
> Cheers,
> Randall


Re: reverse proxy discouraged?

Posted by Randall Leeds <ra...@gmail.com>.
Ahh. I understand your problem.
Your html cannot reference :5984, for cross-domain rules (as you
noted), but instead the path you've forwarded to Couch.
I'm not an apache wizard. I won't even pretend to try to tell you how.
But if the example on the wiki and the apache docs is not enough,
hopefully someone can chime in here or maybe you can find someone on
IRC if you catch them at the right time.

Asking in a more apache-specific forum might also yield some help.
Even if they're not familiar with Couch I assume anyone with
sufficient knowledge of the apache web server should be able to direct
you to how to get X-domain between virtual hosts, if indeed it's
virtual hosts that are the key.

Good luck, Dan! And please, when you find out what you were missing
please tell everyone here and update the wiki with any useful info. I
have a feeling you're not the first nor the last person to try to set
this up.

Cheers,
Randall

Re: reverse proxy discouraged?

Posted by wh...@aol.com.
I'm trying to send commands from html in my apache folder on localhost
to 
localhost:5984 which violates the cross domain policy.

Can rewrites or virtual hosts be used to get around that problem?

Thanks 

Dan


 

 


 

 

-----Original Message-----
From: Tyler Gillies <tj...@gmail.com>
To: user@couchdb.apache.org
Sent: Thu, Aug 19, 2010 4:05 pm
Subject: Re: reverse proxy discouraged?


with reverse proxy you aren't "serving" from apache you're just redirecting

them to couchdb.



couch supports rewrites if you don't want to reverse proxy:

http://blog.couch.io/post/443028592/whats-new-in-apache-couchdb-0-11-part-one-nice-urls



On Thu, Aug 19, 2010 at 3:41 PM, <wh...@aol.com> wrote:



> Is using a reverse proxy to serve up html and couchdb from the same domain

> and port problematic?

> Someone told me that it is highly discouraged

>

> and that html pages should be served from couchdb.

> But on a site that is web 2.0 and has a complicated GUI there would need to

> be 100's of attachments that would be necessary to correctly

> serve up a page as an attachment to a document.

>

> This sounds unreasonable for development where 100's of changes are made

> per day.

>

> The reverse proxy method seems feasible but why would it be discouraged?

>

> Thanks,

>

> Dan

>

>

>

>

>

>

>

>





-- 

PdxBrain <http://www.pdxbrain.com> - My Home


 

Re: reverse proxy discouraged?

Posted by Tyler Gillies <tj...@gmail.com>.
with reverse proxy you aren't "serving" from apache you're just redirecting
them to couchdb.

couch supports rewrites if you don't want to reverse proxy:
http://blog.couch.io/post/443028592/whats-new-in-apache-couchdb-0-11-part-one-nice-urls

On Thu, Aug 19, 2010 at 3:41 PM, <wh...@aol.com> wrote:

> Is using a reverse proxy to serve up html and couchdb from the same domain
> and port problematic?
> Someone told me that it is highly discouraged
>
> and that html pages should be served from couchdb.
> But on a site that is web 2.0 and has a complicated GUI there would need to
> be 100's of attachments that would be necessary to correctly
> serve up a page as an attachment to a document.
>
> This sounds unreasonable for development where 100's of changes are made
> per day.
>
> The reverse proxy method seems feasible but why would it be discouraged?
>
> Thanks,
>
> Dan
>
>
>
>
>
>
>
>


-- 
PdxBrain <http://www.pdxbrain.com> - My Home