You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Jan Lehnardt <ja...@apache.org> on 2010/02/19 00:23:18 UTC

Virtual Hosts

Hi dev@,

I added virtual host handling to CouchDB. I have a Github branch for you to check out:

  http://github.com/janl/couchdb/commits/vhosts

Alternatively, here's a full diff including etap tests: 

  http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf

From local.ini:

; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to
; the Virual Host will be redirected to the path. In the example below all requests
; to http://example.com/ are redirected to /database.
; If you run CouchDB on a specific port, include the port number in the vhost:
; example.com:5984 = /database

[vhosts]
;example.com = /database/

In combination with Benoit's rewriter, this allows you to create virtual hosts with 
really pretty URLs. 

The CouchDB default behaviour isn't changed. CouchDB simply inspects a
request's `Host:` header and maps it against any defined virtual hosts. If a
match is found, CouchDB will make an internal redirect much like the rewriter.

I did a stupid A/B test with Apache Bench and couldn't see any performance
degradation. Feel free to prove me wrong :)

I'd like to commit this to trunk and also backport to 0.11. What do you think?

Thanks for you feedback.

Cheers
Jan
--


Re: Virtual Hosts

Posted by J Chris Anderson <jc...@gmail.com>.
On Feb 18, 2010, at 6:23 PM, Jan Lehnardt wrote:

> Hi dev@,
> 
> I added virtual host handling to CouchDB. I have a Github branch for you to check out:
> 
>  http://github.com/janl/couchdb/commits/vhosts
> 
> Alternatively, here's a full diff including etap tests: 
> 
>  http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf
> 
> From local.ini:
> 
> ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to
> ; the Virual Host will be redirected to the path. In the example below all requests
> ; to http://example.com/ are redirected to /database.
> ; If you run CouchDB on a specific port, include the port number in the vhost:
> ; example.com:5984 = /database
> 
> [vhosts]
> ;example.com = /database/
> 
> In combination with Benoit's rewriter, this allows you to create virtual hosts with 
> really pretty URLs. 
> 
> The CouchDB default behaviour isn't changed. CouchDB simply inspects a
> request's `Host:` header and maps it against any defined virtual hosts. If a
> match is found, CouchDB will make an internal redirect much like the rewriter.
> 
> I did a stupid A/B test with Apache Bench and couldn't see any performance
> degradation. Feel free to prove me wrong :)
> 
> I'd like to commit this to trunk and also backport to 0.11. What do you think?
> 

This code looks really good and simple. Way to go.

+1 on including it in 0.11 as there's really nothing to this (especially for people who don't enable it).

> Thanks for you feedback.
> 
> Cheers
> Jan
> --
> 


Re: Virtual Hosts

Posted by David Goodlad <da...@goodlad.ca>.
On Fri, Feb 19, 2010 at 10:23 AM, Jan Lehnardt <ja...@apache.org> wrote:
> Hi dev@,
>
> I added virtual host handling to CouchDB. I have a Github branch for you to check out:

+1

Re: Virtual Hosts

Posted by Nicholas Orr <ni...@zxgen.net>.
+1 - this will make couchapps a bit prettier :)

On Fri, Feb 19, 2010 at 10:39 AM, Noah Slater <ns...@tumbolia.org> wrote:

> Cool.
>
> On 18 Feb 2010, at 23:36, Jan Lehnardt wrote:
>
> >
> > On 18 Feb 2010, at 15:30, Noah Slater wrote:
> >
> >> What happens when the Host header is absent? Does it default to the
> first one in the file, like Apache httpd?
> >
> > The default case (when there is no Host header (HTTP 1.0) or the host
> header doesn't match any vhost) is to act as if the bind-address + port were
> called, just like before.
> >
> > Cheers
> > Jan
> > --
> >
> >
> >>
> >> On 18 Feb 2010, at 23:23, Jan Lehnardt wrote:
> >>
> >>> Hi dev@,
> >>>
> >>> I added virtual host handling to CouchDB. I have a Github branch for
> you to check out:
> >>>
> >>> http://github.com/janl/couchdb/commits/vhosts
> >>>
> >>> Alternatively, here's a full diff including etap tests:
> >>>
> >>> http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf
> >>>
> >>> From local.ini:
> >>>
> >>> ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All
> requests to
> >>> ; the Virual Host will be redirected to the path. In the example below
> all requests
> >>> ; to http://example.com/ are redirected to /database.
> >>> ; If you run CouchDB on a specific port, include the port number in the
> vhost:
> >>> ; example.com:5984 = /database
> >>>
> >>> [vhosts]
> >>> ;example.com = /database/
> >>>
> >>> In combination with Benoit's rewriter, this allows you to create
> virtual hosts with
> >>> really pretty URLs.
> >>>
> >>> The CouchDB default behaviour isn't changed. CouchDB simply inspects a
> >>> request's `Host:` header and maps it against any defined virtual hosts.
> If a
> >>> match is found, CouchDB will make an internal redirect much like the
> rewriter.
> >>>
> >>> I did a stupid A/B test with Apache Bench and couldn't see any
> performance
> >>> degradation. Feel free to prove me wrong :)
> >>>
> >>> I'd like to commit this to trunk and also backport to 0.11. What do you
> think?
> >>>
> >>> Thanks for you feedback.
> >>>
> >>> Cheers
> >>> Jan
> >>> --
> >>>
> >>
> >
>
>

Re: Virtual Hosts

Posted by Noah Slater <ns...@tumbolia.org>.
Cool.

On 18 Feb 2010, at 23:36, Jan Lehnardt wrote:

> 
> On 18 Feb 2010, at 15:30, Noah Slater wrote:
> 
>> What happens when the Host header is absent? Does it default to the first one in the file, like Apache httpd?
> 
> The default case (when there is no Host header (HTTP 1.0) or the host header doesn't match any vhost) is to act as if the bind-address + port were called, just like before.
> 
> Cheers
> Jan
> --
> 
> 
>> 
>> On 18 Feb 2010, at 23:23, Jan Lehnardt wrote:
>> 
>>> Hi dev@,
>>> 
>>> I added virtual host handling to CouchDB. I have a Github branch for you to check out:
>>> 
>>> http://github.com/janl/couchdb/commits/vhosts
>>> 
>>> Alternatively, here's a full diff including etap tests: 
>>> 
>>> http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf
>>> 
>>> From local.ini:
>>> 
>>> ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to
>>> ; the Virual Host will be redirected to the path. In the example below all requests
>>> ; to http://example.com/ are redirected to /database.
>>> ; If you run CouchDB on a specific port, include the port number in the vhost:
>>> ; example.com:5984 = /database
>>> 
>>> [vhosts]
>>> ;example.com = /database/
>>> 
>>> In combination with Benoit's rewriter, this allows you to create virtual hosts with 
>>> really pretty URLs. 
>>> 
>>> The CouchDB default behaviour isn't changed. CouchDB simply inspects a
>>> request's `Host:` header and maps it against any defined virtual hosts. If a
>>> match is found, CouchDB will make an internal redirect much like the rewriter.
>>> 
>>> I did a stupid A/B test with Apache Bench and couldn't see any performance
>>> degradation. Feel free to prove me wrong :)
>>> 
>>> I'd like to commit this to trunk and also backport to 0.11. What do you think?
>>> 
>>> Thanks for you feedback.
>>> 
>>> Cheers
>>> Jan
>>> --
>>> 
>> 
> 


Re: Virtual Hosts

Posted by Jan Lehnardt <ja...@apache.org>.
On 18 Feb 2010, at 15:30, Noah Slater wrote:

> What happens when the Host header is absent? Does it default to the first one in the file, like Apache httpd?

The default case (when there is no Host header (HTTP 1.0) or the host header doesn't match any vhost) is to act as if the bind-address + port were called, just like before.

Cheers
Jan
--


> 
> On 18 Feb 2010, at 23:23, Jan Lehnardt wrote:
> 
>> Hi dev@,
>> 
>> I added virtual host handling to CouchDB. I have a Github branch for you to check out:
>> 
>> http://github.com/janl/couchdb/commits/vhosts
>> 
>> Alternatively, here's a full diff including etap tests: 
>> 
>> http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf
>> 
>> From local.ini:
>> 
>> ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to
>> ; the Virual Host will be redirected to the path. In the example below all requests
>> ; to http://example.com/ are redirected to /database.
>> ; If you run CouchDB on a specific port, include the port number in the vhost:
>> ; example.com:5984 = /database
>> 
>> [vhosts]
>> ;example.com = /database/
>> 
>> In combination with Benoit's rewriter, this allows you to create virtual hosts with 
>> really pretty URLs. 
>> 
>> The CouchDB default behaviour isn't changed. CouchDB simply inspects a
>> request's `Host:` header and maps it against any defined virtual hosts. If a
>> match is found, CouchDB will make an internal redirect much like the rewriter.
>> 
>> I did a stupid A/B test with Apache Bench and couldn't see any performance
>> degradation. Feel free to prove me wrong :)
>> 
>> I'd like to commit this to trunk and also backport to 0.11. What do you think?
>> 
>> Thanks for you feedback.
>> 
>> Cheers
>> Jan
>> --
>> 
> 


Re: Virtual Hosts

Posted by Noah Slater <ns...@tumbolia.org>.
What happens when the Host header is absent? Does it default to the first one in the file, like Apache httpd?

On 18 Feb 2010, at 23:23, Jan Lehnardt wrote:

> Hi dev@,
> 
> I added virtual host handling to CouchDB. I have a Github branch for you to check out:
> 
>  http://github.com/janl/couchdb/commits/vhosts
> 
> Alternatively, here's a full diff including etap tests: 
> 
>  http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf
> 
> From local.ini:
> 
> ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to
> ; the Virual Host will be redirected to the path. In the example below all requests
> ; to http://example.com/ are redirected to /database.
> ; If you run CouchDB on a specific port, include the port number in the vhost:
> ; example.com:5984 = /database
> 
> [vhosts]
> ;example.com = /database/
> 
> In combination with Benoit's rewriter, this allows you to create virtual hosts with 
> really pretty URLs. 
> 
> The CouchDB default behaviour isn't changed. CouchDB simply inspects a
> request's `Host:` header and maps it against any defined virtual hosts. If a
> match is found, CouchDB will make an internal redirect much like the rewriter.
> 
> I did a stupid A/B test with Apache Bench and couldn't see any performance
> degradation. Feel free to prove me wrong :)
> 
> I'd like to commit this to trunk and also backport to 0.11. What do you think?
> 
> Thanks for you feedback.
> 
> Cheers
> Jan
> --
> 


Re: Virtual Hosts

Posted by Robert Dionne <di...@dionne-associates.com>.
+1 -- looks nice and simple



On Feb 18, 2010, at 6:23 PM, Jan Lehnardt wrote:

> Hi dev@,
> 
> I added virtual host handling to CouchDB. I have a Github branch for you to check out:
> 
>  http://github.com/janl/couchdb/commits/vhosts
> 
> Alternatively, here's a full diff including etap tests: 
> 
>  http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf
> 
> From local.ini:
> 
> ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to
> ; the Virual Host will be redirected to the path. In the example below all requests
> ; to http://example.com/ are redirected to /database.
> ; If you run CouchDB on a specific port, include the port number in the vhost:
> ; example.com:5984 = /database
> 
> [vhosts]
> ;example.com = /database/
> 
> In combination with Benoit's rewriter, this allows you to create virtual hosts with 
> really pretty URLs. 
> 
> The CouchDB default behaviour isn't changed. CouchDB simply inspects a
> request's `Host:` header and maps it against any defined virtual hosts. If a
> match is found, CouchDB will make an internal redirect much like the rewriter.
> 
> I did a stupid A/B test with Apache Bench and couldn't see any performance
> degradation. Feel free to prove me wrong :)
> 
> I'd like to commit this to trunk and also backport to 0.11. What do you think?
> 
> Thanks for you feedback.
> 
> Cheers
> Jan
> --
> 


Re: Virtual Hosts

Posted by Jan Lehnardt <ja...@apache.org>.
Thanks for all the +1s :) This is now in trunk and 0.11.

Cheers
Jan
--
PS: I accidentally backported my whitespace fixes from 
yesterday too, nothing to worry about, just in case you
wonder.


On 18 Feb 2010, at 15:23, Jan Lehnardt wrote:

> Hi dev@,
> 
> I added virtual host handling to CouchDB. I have a Github branch for you to check out:
> 
>  http://github.com/janl/couchdb/commits/vhosts
> 
> Alternatively, here's a full diff including etap tests: 
> 
>  http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf
> 
> From local.ini:
> 
> ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to
> ; the Virual Host will be redirected to the path. In the example below all requests
> ; to http://example.com/ are redirected to /database.
> ; If you run CouchDB on a specific port, include the port number in the vhost:
> ; example.com:5984 = /database
> 
> [vhosts]
> ;example.com = /database/
> 
> In combination with Benoit's rewriter, this allows you to create virtual hosts with 
> really pretty URLs. 
> 
> The CouchDB default behaviour isn't changed. CouchDB simply inspects a
> request's `Host:` header and maps it against any defined virtual hosts. If a
> match is found, CouchDB will make an internal redirect much like the rewriter.
> 
> I did a stupid A/B test with Apache Bench and couldn't see any performance
> degradation. Feel free to prove me wrong :)
> 
> I'd like to commit this to trunk and also backport to 0.11. What do you think?
> 
> Thanks for you feedback.
> 
> Cheers
> Jan
> --
> 


Re: Virtual Hosts

Posted by Filipe David Manana <fd...@gmail.com>.
+1 also :)

On Fri, Feb 19, 2010 at 12:23 AM, Jan Lehnardt <ja...@apache.org> wrote:

> Hi dev@,
>
> I added virtual host handling to CouchDB. I have a Github branch for you to
> check out:
>
>  http://github.com/janl/couchdb/commits/vhosts
>
> Alternatively, here's a full diff including etap tests:
>
>  http://www.friendpaste.com/6B5dQU1fb27boOvxhm2nhf
>
> From local.ini:
>
> ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All
> requests to
> ; the Virual Host will be redirected to the path. In the example below all
> requests
> ; to http://example.com/ are redirected to /database.
> ; If you run CouchDB on a specific port, include the port number in the
> vhost:
> ; example.com:5984 = /database
>
> [vhosts]
> ;example.com = /database/
>
> In combination with Benoit's rewriter, this allows you to create virtual
> hosts with
> really pretty URLs.
>
> The CouchDB default behaviour isn't changed. CouchDB simply inspects a
> request's `Host:` header and maps it against any defined virtual hosts. If
> a
> match is found, CouchDB will make an internal redirect much like the
> rewriter.
>
> I did a stupid A/B test with Apache Bench and couldn't see any performance
> degradation. Feel free to prove me wrong :)
>
> I'd like to commit this to trunk and also backport to 0.11. What do you
> think?
>
> Thanks for you feedback.
>
> Cheers
> Jan
> --
>
>


-- 
Filipe David Manana,
fdmanana@gmail.com
PGP key - http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC569452B

"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."

Re: Virtual Hosts

Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Feb 19, 2010 at 12:23 AM, Jan Lehnardt <ja...@apache.org> wrote:
e me wrong :)
>
> I'd like to commit this to trunk and also backport to 0.11. What do you think?
>
+1

- benoit