You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rich Bowen <rb...@rcbowen.com> on 2010/11/10 16:35:24 UTC

SetVirtualDocumentRoot

I was reading bug reports this morning, and wondered if someone could  
take a look at the patch offered here:

https://issues.apache.org/bugzilla/show_bug.cgi?id=26052#c19

It adds a SetVirtualDocumentRoot configuration directive to  
mod_vhost_alias, making numerous third-party applications behave  
sanely when run under mod_vhost_alias.

I've read the various justifications why we don't do this, and quite  
frankly I don't understand them. Is there a legitimate reason that  
setting DOCUMENT_ROOT on a per-dynamic-vhost basis is any different/ 
worse than setting it on a per-regular-vhost basis? I don't understand  
the distinction, other than "we've never done it that way."

Thanks.

--
Rich Bowen
rbowen@rcbowen.com


Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by Ondřej Surý <on...@sury.org>.
On Mon, Dec 20, 2010 at 00:27, Stefan Fritsch <sf...@sfritsch.de> wrote:
> On Monday 13 December 2010, William A. Rowe Jr. wrote:
>> On 12/13/2010 4:35 AM, Stefan Fritsch wrote:
>> > On Monday 13 December 2010, Ondřej Surý wrote:
>> >> On Mon, Dec 13, 2010 at 04:15, William A. Rowe Jr. <wrowe@rowe-
>> >
>> > clan.net> wrote:
>> >>> On 12/12/2010 4:23 PM, Stefan Fritsch wrote:
>> >>>> On Wednesday 10 November 2010, Stefan Fritsch wrote:
>> >>>>>> The frequency with which this gets asked seems to make it
>> >>>>>> worthwhile doing something, even if this patch isn't the
>> >>>>>> right thing to do.
>> >>>>>
>> >>>>> Maybe the larger solution of having a document_root field in
>> >>>>> the request_rec would be better. Has anyone had a chance to
>> >>>>> look at Ondrej's patch, already? I didn't get around to doing
>> >>>>> it, yet.
>> >>>>>
>> >>>>> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705
>> >>>>
>> >>>> I have looked at the patch and it looks reasonable. The fact
>> >>>> that two known modules (mod_vhost_ldap and mod_ftp) copy the
>> >>>> whole server_rec just to change the document root means that
>> >>>> this feature is needed.
>> >>>>
>> >>>> Well, at least for mod_ftp it is...
>> >>>>
>> >>>> I am wondering if the people who want this for mod_vhost_*
>> >>>> actually want something else, namely an easy way to get the
>> >>>> root dir of a web application in php/cgi/whatever...
>> >>>>
>> >>>> What about this idea:
>> >>>>
>> >>>> Add two new cgi env variables: CONTEXT_ROOT and
>> >>>> CONTEXT_ROOT_PATH (or APP_ROOT/APP_ROOT_PATH or ...). And add
>> >>>> a new config directive
>> >>>
>> >>> Feh... DOCUMENT_ROOT was bad enough, do we have to persist the
>> >>> concept of sharing such things with the app?  For that matter,
>> >>> what are the vars that are used in app doc models today, why
>> >>> would we have to invent this again?
>> >
>> > These things are handled nicely in the JEE world by AJP and the
>> > servlet container. They don't seem to work all that well in the
>> > CGI-/PHP-world.
>>
>> So before inventing semantics, pointers to the Servlet semantics
>> and/or the ASP.NET semantics would be appropriate, and discuss an
>> established model and naming conventions you've already identified
>> as working nicely. No?
>
> JEE has the notion of a servlet context which has a context root path.
> Servlets only need to know paths relative to the context root and can
> use the methods getRealPath() to convert it into a file system path
> and getResource() to convert it into an URI. [1]
>
> This does of course not map directly to CGI scripts. But my idea was
> that the script only knows the path relative to the context root and
> then prepends the variables CONTEXT_ROOT or CONTEXT_ROOT_PATH to get a
> URI or file system path, respectively. Maybe CONTEXT_ROOT should be
> named CONTEXT_ROOT_URI instead.
>
> I really think having two such variables always defined to the correct
> values (even with mod_alias/mod_userdir/ssl-offload/...) would be a
> good thing, even if it takes a few years until they get adopted by web
> applications.

Stefan, it doesn't have to take a long time. If you are willing to
backport the patch to next stable Debian (or if this gets enough
attention and it will get adopted to 2.4 and next stable will have
2.4), we can adopt it for PHP5 as soon as this hits the unstable.

I would be more then happy to do such work and modify my patch to not
touch DOCUMENT_ROOT, but create new per-request CONTEXT_ROOT. E.g. if
we can agree how to proceed I am willing to throw my hands on such
code.

Ondrej
-- 
Ondřej Surý <on...@sury.org>

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Monday 13 December 2010, William A. Rowe Jr. wrote:
> On 12/13/2010 4:35 AM, Stefan Fritsch wrote:
> > On Monday 13 December 2010, Ondřej Surý wrote:
> >> On Mon, Dec 13, 2010 at 04:15, William A. Rowe Jr. <wrowe@rowe-
> > 
> > clan.net> wrote:
> >>> On 12/12/2010 4:23 PM, Stefan Fritsch wrote:
> >>>> On Wednesday 10 November 2010, Stefan Fritsch wrote:
> >>>>>> The frequency with which this gets asked seems to make it
> >>>>>> worthwhile doing something, even if this patch isn't the
> >>>>>> right thing to do.
> >>>>> 
> >>>>> Maybe the larger solution of having a document_root field in
> >>>>> the request_rec would be better. Has anyone had a chance to
> >>>>> look at Ondrej's patch, already? I didn't get around to doing
> >>>>> it, yet.
> >>>>> 
> >>>>> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705
> >>>> 
> >>>> I have looked at the patch and it looks reasonable. The fact
> >>>> that two known modules (mod_vhost_ldap and mod_ftp) copy the
> >>>> whole server_rec just to change the document root means that
> >>>> this feature is needed.
> >>>> 
> >>>> Well, at least for mod_ftp it is...
> >>>> 
> >>>> I am wondering if the people who want this for mod_vhost_*
> >>>> actually want something else, namely an easy way to get the
> >>>> root dir of a web application in php/cgi/whatever...
> >>>> 
> >>>> What about this idea:
> >>>> 
> >>>> Add two new cgi env variables: CONTEXT_ROOT and
> >>>> CONTEXT_ROOT_PATH (or APP_ROOT/APP_ROOT_PATH or ...). And add
> >>>> a new config directive
> >>> 
> >>> Feh... DOCUMENT_ROOT was bad enough, do we have to persist the
> >>> concept of sharing such things with the app?  For that matter,
> >>> what are the vars that are used in app doc models today, why
> >>> would we have to invent this again?
> > 
> > These things are handled nicely in the JEE world by AJP and the
> > servlet container. They don't seem to work all that well in the
> > CGI-/PHP-world.
> 
> So before inventing semantics, pointers to the Servlet semantics
> and/or the ASP.NET semantics would be appropriate, and discuss an
> established model and naming conventions you've already identified
> as working nicely. No?

JEE has the notion of a servlet context which has a context root path. 
Servlets only need to know paths relative to the context root and can 
use the methods getRealPath() to convert it into a file system path 
and getResource() to convert it into an URI. [1]

This does of course not map directly to CGI scripts. But my idea was 
that the script only knows the path relative to the context root and 
then prepends the variables CONTEXT_ROOT or CONTEXT_ROOT_PATH to get a 
URI or file system path, respectively. Maybe CONTEXT_ROOT should be 
named CONTEXT_ROOT_URI instead.

I really think having two such variables always defined to the correct 
values (even with mod_alias/mod_userdir/ssl-offload/...) would be a 
good thing, even if it takes a few years until they get adopted by web 
applications.

I don't know how .NET handles this, exactly. But from a bit of 
googling it seems that the context root may be equivalent to the 
metabase path.

[1] 
http://download.oracle.com/javaee/6/api/javax/servlet/ServletContext.html

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by Ondřej Surý <on...@sury.org>.
On Mon, Dec 13, 2010 at 11:35, Stefan Fritsch <sf...@sfritsch.de> wrote:
> On Monday 13 December 2010, Ondřej Surý wrote:
>> On Mon, Dec 13, 2010 at 04:15, William A. Rowe Jr. <wrowe@rowe-
> clan.net> wrote:
>> > On 12/12/2010 4:23 PM, Stefan Fritsch wrote:
>> >> On Wednesday 10 November 2010, Stefan Fritsch wrote:
>> >>>> The frequency with which this gets asked seems to make it
>> >>>> worthwhile doing something, even if this patch isn't the right
>> >>>> thing to do.
>> >>>
>> >>> Maybe the larger solution of having a document_root field in
>> >>> the request_rec would be better. Has anyone had a chance to
>> >>> look at Ondrej's patch, already? I didn't get around to doing
>> >>> it, yet.
>> >>>
>> >>> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705
>> >>
>> >> I have looked at the patch and it looks reasonable. The fact
>> >> that two known modules (mod_vhost_ldap and mod_ftp) copy the
>> >> whole server_rec just to change the document root means that
>> >> this feature is needed.
>> >>
>> >> Well, at least for mod_ftp it is...
>> >>
>> >> I am wondering if the people who want this for mod_vhost_*
>> >> actually want something else, namely an easy way to get the
>> >> root dir of a web application in php/cgi/whatever...
>> >>
>> >> What about this idea:
>> >>
>> >> Add two new cgi env variables: CONTEXT_ROOT and
>> >> CONTEXT_ROOT_PATH (or APP_ROOT/APP_ROOT_PATH or ...). And add a
>> >> new config directive
>> >
>> > Feh... DOCUMENT_ROOT was bad enough, do we have to persist the
>> > concept of sharing such things with the app?  For that matter,
>> > what are the vars that are used in app doc models today, why
>> > would we have to invent this again?
>
> These things are handled nicely in the JEE world by AJP and the
> servlet container. They don't seem to work all that well in the
> CGI-/PHP-world.
>
> And DOCUMENT_ROOT is broken if used with mod_alias or mod_userdir. Why
> not replace it with something that works? A different idea with no
> additional directive:
>
> BASE_PATH points to the filesystem path of an
> alias/userdir/documentroot
>
> BASE_URI points to the URI prefix that is equivalent to BASE_PATH.
> Maybe this should already include scheme and hostname, to take care of
> ssl-offload, reverse proxies, etc.
>
> A self-referential URL could then be constructed by cutting BASE_PATH
> from SCRIPT_FILENAME and prepending BASE_URI.
>
>> It's not only about the DOCUMENT_ROOT variable. The main problem is
>> interaction with other modules. Mainly mod_rewrite, which uses the
>> document root for -f and -d checks.
>
> mod_rewrite could then use BASE_PATH instead of DOCUMENT_ROOT, in
> order to keep working in presence of aliases, etc.

Seems to be a good idea (although it creates need to patch many thing
beyond the apache core). I would be happy to throw some code (could be
based on my earlier patch) to make this happen.

CGI handling is broken in m-v-l anyway, since I wasn't able to figure
out how to put the pieces of ap_document_root and mod_cgi(d) together.
However it's on my todo list (and since I already have two bug
reports, I ought to fix it sooner or later...)

Ondrej
-- 
Ondřej Surý <on...@sury.org>

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 12/13/2010 4:35 AM, Stefan Fritsch wrote:
> On Monday 13 December 2010, Ondřej Surý wrote:
>> On Mon, Dec 13, 2010 at 04:15, William A. Rowe Jr. <wrowe@rowe-
> clan.net> wrote:
>>> On 12/12/2010 4:23 PM, Stefan Fritsch wrote:
>>>> On Wednesday 10 November 2010, Stefan Fritsch wrote:
>>>>>> The frequency with which this gets asked seems to make it
>>>>>> worthwhile doing something, even if this patch isn't the right
>>>>>> thing to do.
>>>>>
>>>>> Maybe the larger solution of having a document_root field in
>>>>> the request_rec would be better. Has anyone had a chance to
>>>>> look at Ondrej's patch, already? I didn't get around to doing
>>>>> it, yet.
>>>>>
>>>>> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705
>>>>
>>>> I have looked at the patch and it looks reasonable. The fact
>>>> that two known modules (mod_vhost_ldap and mod_ftp) copy the
>>>> whole server_rec just to change the document root means that
>>>> this feature is needed.
>>>>
>>>> Well, at least for mod_ftp it is...
>>>>
>>>> I am wondering if the people who want this for mod_vhost_*
>>>> actually want something else, namely an easy way to get the
>>>> root dir of a web application in php/cgi/whatever...
>>>>
>>>> What about this idea:
>>>>
>>>> Add two new cgi env variables: CONTEXT_ROOT and
>>>> CONTEXT_ROOT_PATH (or APP_ROOT/APP_ROOT_PATH or ...). And add a
>>>> new config directive
>>>
>>> Feh... DOCUMENT_ROOT was bad enough, do we have to persist the
>>> concept of sharing such things with the app?  For that matter,
>>> what are the vars that are used in app doc models today, why
>>> would we have to invent this again?
> 
> These things are handled nicely in the JEE world by AJP and the 
> servlet container. They don't seem to work all that well in the 
> CGI-/PHP-world.

So before inventing semantics, pointers to the Servlet semantics and/or
the ASP.NET semantics would be appropriate, and discuss an established
model and naming conventions you've already identified as working nicely.
No?

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Monday 13 December 2010, Ondřej Surý wrote:
> On Mon, Dec 13, 2010 at 04:15, William A. Rowe Jr. <wrowe@rowe-
clan.net> wrote:
> > On 12/12/2010 4:23 PM, Stefan Fritsch wrote:
> >> On Wednesday 10 November 2010, Stefan Fritsch wrote:
> >>>> The frequency with which this gets asked seems to make it
> >>>> worthwhile doing something, even if this patch isn't the right
> >>>> thing to do.
> >>> 
> >>> Maybe the larger solution of having a document_root field in
> >>> the request_rec would be better. Has anyone had a chance to
> >>> look at Ondrej's patch, already? I didn't get around to doing
> >>> it, yet.
> >>> 
> >>> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705
> >> 
> >> I have looked at the patch and it looks reasonable. The fact
> >> that two known modules (mod_vhost_ldap and mod_ftp) copy the
> >> whole server_rec just to change the document root means that
> >> this feature is needed.
> >> 
> >> Well, at least for mod_ftp it is...
> >> 
> >> I am wondering if the people who want this for mod_vhost_*
> >> actually want something else, namely an easy way to get the
> >> root dir of a web application in php/cgi/whatever...
> >> 
> >> What about this idea:
> >> 
> >> Add two new cgi env variables: CONTEXT_ROOT and
> >> CONTEXT_ROOT_PATH (or APP_ROOT/APP_ROOT_PATH or ...). And add a
> >> new config directive
> > 
> > Feh... DOCUMENT_ROOT was bad enough, do we have to persist the
> > concept of sharing such things with the app?  For that matter,
> > what are the vars that are used in app doc models today, why
> > would we have to invent this again?

These things are handled nicely in the JEE world by AJP and the 
servlet container. They don't seem to work all that well in the 
CGI-/PHP-world.

And DOCUMENT_ROOT is broken if used with mod_alias or mod_userdir. Why 
not replace it with something that works? A different idea with no 
additional directive:

BASE_PATH points to the filesystem path of an 
alias/userdir/documentroot

BASE_URI points to the URI prefix that is equivalent to BASE_PATH.
Maybe this should already include scheme and hostname, to take care of 
ssl-offload, reverse proxies, etc.

A self-referential URL could then be constructed by cutting BASE_PATH 
from SCRIPT_FILENAME and prepending BASE_URI.


> It's not only about the DOCUMENT_ROOT variable. The main problem is
> interaction with other modules. Mainly mod_rewrite, which uses the
> document root for -f and -d checks.

mod_rewrite could then use BASE_PATH instead of DOCUMENT_ROOT, in 
order to keep working in presence of aliases, etc.

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 12/13/2010 2:33 AM, Ondřej Surý wrote:
> 
> It's not only about the DOCUMENT_ROOT variable. The main problem is
> interaction with other modules. Mainly mod_rewrite, which uses the
> document root for -f and -d checks.

Mainly...

arguably, mod_rewrite may be in the wrong here.

So before discussing that specific case, what *other* modules use the
document_root in non-CGI manners?

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by Ondřej Surý <on...@sury.org>.
On Mon, Dec 13, 2010 at 04:15, William A. Rowe Jr. <wr...@rowe-clan.net> wrote:
> On 12/12/2010 4:23 PM, Stefan Fritsch wrote:
>> On Wednesday 10 November 2010, Stefan Fritsch wrote:
>>>> The frequency with which this gets asked seems to make it
>>>> worthwhile doing something, even if this patch isn't the right
>>>> thing to do.
>>>
>>> Maybe the larger solution of having a document_root field in the
>>> request_rec would be better. Has anyone had a chance to look at
>>> Ondrej's patch, already? I didn't get around to doing it, yet.
>>>
>>> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705
>>
>> I have looked at the patch and it looks reasonable. The fact that two
>> known modules (mod_vhost_ldap and mod_ftp) copy the whole server_rec
>> just to change the document root means that this feature is needed.
>>
>> Well, at least for mod_ftp it is...
>>
>> I am wondering if the people who want this for mod_vhost_* actually
>> want something else, namely an easy way to get the root dir of a web
>> application in php/cgi/whatever...
>>
>> What about this idea:
>>
>> Add two new cgi env variables: CONTEXT_ROOT and CONTEXT_ROOT_PATH (or
>> APP_ROOT/APP_ROOT_PATH or ...). And add a new config directive
>
> Feh... DOCUMENT_ROOT was bad enough, do we have to persist the concept
> of sharing such things with the app?  For that matter, what are the vars
> that are used in app doc models today, why would we have to invent this
> again?

It's not only about the DOCUMENT_ROOT variable. The main problem is
interaction with other modules. Mainly mod_rewrite, which uses the
document root for -f and -d checks.

And as I said earlier the copy-whole-server_rec technique doesn't work
here because mod_rewrite checks whether the server_rec is same in
request and in conf:

    /*
     *  check for the ugly API case of a virtual host section where no
     *  mod_rewrite directives exists. In this situation we became no chance
     *  by the API to setup our default per-server config so we have to
     *  on-the-fly assume we have the default config. But because the default
     *  config has a disabled rewriting engine we are lucky because can
     *  just stop operating now.
     */
    if (conf->server != r->server) {
        return DECLINED;
    }


Ondrej
-- 
Ondřej Surý <on...@sury.org>

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 12/12/2010 4:23 PM, Stefan Fritsch wrote:
> On Wednesday 10 November 2010, Stefan Fritsch wrote:
>>> The frequency with which this gets asked seems to make it
>>> worthwhile doing something, even if this patch isn't the right
>>> thing to do.
>>
>> Maybe the larger solution of having a document_root field in the 
>> request_rec would be better. Has anyone had a chance to look at 
>> Ondrej's patch, already? I didn't get around to doing it, yet.
>>
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705
> 
> I have looked at the patch and it looks reasonable. The fact that two 
> known modules (mod_vhost_ldap and mod_ftp) copy the whole server_rec 
> just to change the document root means that this feature is needed.
> 
> Well, at least for mod_ftp it is...
> 
> I am wondering if the people who want this for mod_vhost_* actually 
> want something else, namely an easy way to get the root dir of a web 
> application in php/cgi/whatever...
> 
> What about this idea:
> 
> Add two new cgi env variables: CONTEXT_ROOT and CONTEXT_ROOT_PATH (or 
> APP_ROOT/APP_ROOT_PATH or ...). And add a new config directive

Feh... DOCUMENT_ROOT was bad enough, do we have to persist the concept
of sharing such things with the app?  For that matter, what are the vars
that are used in app doc models today, why would we have to invent this
again?

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 12/13/2010 5:08 AM, Graham Leggett wrote:
> On 13 Dec 2010, at 5:11 AM, William A. Rowe Jr. wrote:
> 
>>> An idea from left field.
>>>
>>> Is there a reason that DocumentRoot is a virtual host wide setting?
>>
>> Yes, root describes "/", there is only one <Location "/">.
> 
> I can understand why such a setting would be required, but I still don't see why that
> requirement binds us to it being set virtual host wide.

I don't see why it's required, and I don't see why you keep talking of other locations.

> You could either treat the lack of a DocumentRoot defined at the / level as a fatal error
> that prevents the server from starting, or you could fall back on a precompiled default
> directory.

There isn't another level.  It says Root, root == "/".

> In theory, the only reason I can see for requiring it virtual host wide is if the value is
> required before the location walk. Is it?

Ideally, the lack of a DocumentRoot/Alias/MountFilePath indicates there is no file
content.  The location walk NEVER disappears.  But Directory walk could be bypassed
entirely, with a default no_document handler returning a 404.

Since there can be only one path to which a Root applies, placing Root directives
at the Server level is entirely sensible.

>>> Does it not make sense to make it per-Location instead?
>>
>> No, but MountFilePath /path/to/foo in a Location basis makes sense.
> 
> What I had in mind was:
> 
> DocumentRoot /somewhere
> <Location /bar>
>   DocumentRoot /somewhereelse
> </Location>

No, because that is not a root.  Sorry, the english language overrides your
proposed semantics.

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by Graham Leggett <mi...@sharp.fm>.
On 13 Dec 2010, at 5:11 AM, William A. Rowe Jr. wrote:

>> An idea from left field.
>>
>> Is there a reason that DocumentRoot is a virtual host wide setting?
>
> Yes, root describes "/", there is only one <Location "/">.

I can understand why such a setting would be required, but I still  
don't see why that requirement binds us to it being set virtual host  
wide.

You could either treat the lack of a DocumentRoot defined at the /  
level as a fatal error that prevents the server from starting, or you  
could fall back on a precompiled default directory.

In theory, the only reason I can see for requiring it virtual host  
wide is if the value is required before the location walk. Is it?

>> Does it not make sense to make it per-Location instead?
>
> No, but MountFilePath /path/to/foo in a Location basis makes sense.

What I had in mind was:

DocumentRoot /somewhere
<Location /bar>
   DocumentRoot /somewhereelse
</Location>

which would be equivalent to MountFilePath.

> You might think I just said the same thing, but I had brought this up
> before back around the beginnings of 2.0.  DocumentRoot is an awfully
> ancient and limiting construct.  Some suggest Alias is the same thing
> (which it is, in one sense), but it seems like we could fold both into
> a single concept.
>
> The reason you are still stuck with legacy docroot constructs is  
> CGI, etc.

I don't mind being stuck with legacy docroot constructs, however I do  
see a different way of implementing them though, and I entirely agree  
on the assessment that it is ancient and limiting, which is why I am  
exploring the options by asking "what if".

Regards,
Graham
--


Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 12/12/2010 5:56 PM, Graham Leggett wrote:
> On 13 Dec 2010, at 12:23 AM, Stefan Fritsch wrote:
> 
>> I have looked at the patch and it looks reasonable. The fact that two
>> known modules (mod_vhost_ldap and mod_ftp) copy the whole server_rec
>> just to change the document root means that this feature is needed.
> 
> An idea from left field.
> 
> Is there a reason that DocumentRoot is a virtual host wide setting?

Yes, root describes "/", there is only one <Location "/">.

> Does it not make sense to make it per-Location instead?

No, but MountFilePath /path/to/foo in a Location basis makes sense.

You might think I just said the same thing, but I had brought this up
before back around the beginnings of 2.0.  DocumentRoot is an awfully
ancient and limiting construct.  Some suggest Alias is the same thing
(which it is, in one sense), but it seems like we could fold both into
a single concept.

The reason you are still stuck with legacy docroot constructs is CGI, etc.

Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by Graham Leggett <mi...@sharp.fm>.
On 13 Dec 2010, at 12:23 AM, Stefan Fritsch wrote:

> I have looked at the patch and it looks reasonable. The fact that two
> known modules (mod_vhost_ldap and mod_ftp) copy the whole server_rec
> just to change the document root means that this feature is needed.

An idea from left field.

Is there a reason that DocumentRoot is a virtual host wide setting?

Does it not make sense to make it per-Location instead?

Regards,
Graham
--


Re: SetVirtualDocumentRoot / per request document root / context root?

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Wednesday 10 November 2010, Stefan Fritsch wrote:
> > The frequency with which this gets asked seems to make it
> > worthwhile doing something, even if this patch isn't the right
> > thing to do.
> 
> Maybe the larger solution of having a document_root field in the 
> request_rec would be better. Has anyone had a chance to look at 
> Ondrej's patch, already? I didn't get around to doing it, yet.
> 
> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705

I have looked at the patch and it looks reasonable. The fact that two 
known modules (mod_vhost_ldap and mod_ftp) copy the whole server_rec 
just to change the document root means that this feature is needed.

Well, at least for mod_ftp it is...

I am wondering if the people who want this for mod_vhost_* actually 
want something else, namely an easy way to get the root dir of a web 
application in php/cgi/whatever...

What about this idea:

Add two new cgi env variables: CONTEXT_ROOT and CONTEXT_ROOT_PATH (or 
APP_ROOT/APP_ROOT_PATH or ...). And add a new config directive

ContextRoot /some/app/

For all requests below /some/app/, this would set CONTEXT_ROOT to
/some/app/ and CONTEXT_ROOT_PATH to whatever dir this URL maps to in 
the file system (taking into account mod_userdir, mod_alias, etc.). 
This would make it easier for applications to find their files and to 
create self-referential URLs.

In absense of a ContextRoot directive, the variables would be set to 
the current alias root-uri and dir, or to the document root and "/". 
Mod_userdir could set them to the /~user/ and /home/user/public_html.

There could even be some logic in mod_proxy that passes the correct 
URI to the backend server, so that the CONTEXT_ROOT variable would 
actually represent the URI as seen by the client.

Is this a good idea? Would this solve real-world problems?

Re: SetVirtualDocumentRoot

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Wednesday 10 November 2010, Rich Bowen wrote:
> On Nov 10, 2010, at 11:26 AM, Plüm, Rüdiger, VF-Group wrote:
> >> -----Original Message-----
> >> From: Rich Bowen
> >> To: dev@httpd.apache.org
> >> Subject: SetVirtualDocumentRoot
> >> 
> >> I was reading bug reports this morning, and wondered if
> >> someone could
> >> take a look at the patch offered here:
> >> 
> >> https://issues.apache.org/bugzilla/show_bug.cgi?id=26052#c19
> > 
> > The patch doesn't look appealing to me. Having a module changing
> > the core config
> > on the fly always looks nasty to me, even more so if it stores
> > data in the core config
> > structure that is allocated from a request pool. IMHO this is
> > waiting for all
> > nasty things to happen, SEGFAULT at best.
> 
> Ok. Fair enough. How about something that set the ENV var for just
> the current request?
> 
> The frequency with which this gets asked seems to make it
> worthwhile doing something, even if this patch isn't the right
> thing to do.

Maybe the larger solution of having a document_root field in the 
request_rec would be better. Has anyone had a chance to look at 
Ondrej's patch, already? I didn't get around to doing it, yet.

https://issues.apache.org/bugzilla/show_bug.cgi?id=49705


RE: SetVirtualDocumentRoot

Posted by "Plüm, Rüdiger, VF-Group" <ru...@vodafone.com>.
 

> -----Original Message-----
> From: Rich Bowen 
> Sent: Mittwoch, 10. November 2010 17:35
> To: dev@httpd.apache.org
> Subject: Re: SetVirtualDocumentRoot
> 
> 
> On Nov 10, 2010, at 11:26 AM, Plüm, Rüdiger, VF-Group wrote:
> 
> >> -----Original Message-----
> >> From: Rich Bowen
> >> To: dev@httpd.apache.org
> >> Subject: SetVirtualDocumentRoot
> >>
> >> I was reading bug reports this morning, and wondered if
> >> someone could
> >> take a look at the patch offered here:
> >>
> >> https://issues.apache.org/bugzilla/show_bug.cgi?id=26052#c19
> >
> > The patch doesn't look appealing to me. Having a module 
> changing the  
> > core config
> > on the fly always looks nasty to me, even more so if it 
> stores data  
> > in the core config
> > structure that is allocated from a request pool. IMHO this is  
> > waiting for all
> > nasty things to happen, SEGFAULT at best.
> 
> Ok. Fair enough. How about something that set the ENV var for 
> just the  
> current request?
> 
> The frequency with which this gets asked seems to make it worthwhile  
> doing something, even if this patch isn't the right thing to do.

My comment was only about the patch itself. I am yet undecided on the
feature itself, but being +0 currently means I am in nobodys way :-).

Regards

Rüdiger


Re: SetVirtualDocumentRoot

Posted by Rich Bowen <rb...@rcbowen.com>.
On Nov 10, 2010, at 11:26 AM, Plüm, Rüdiger, VF-Group wrote:

>> -----Original Message-----
>> From: Rich Bowen
>> To: dev@httpd.apache.org
>> Subject: SetVirtualDocumentRoot
>>
>> I was reading bug reports this morning, and wondered if
>> someone could
>> take a look at the patch offered here:
>>
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=26052#c19
>
> The patch doesn't look appealing to me. Having a module changing the  
> core config
> on the fly always looks nasty to me, even more so if it stores data  
> in the core config
> structure that is allocated from a request pool. IMHO this is  
> waiting for all
> nasty things to happen, SEGFAULT at best.

Ok. Fair enough. How about something that set the ENV var for just the  
current request?

The frequency with which this gets asked seems to make it worthwhile  
doing something, even if this patch isn't the right thing to do.

--
Rich Bowen
rbowen@rcbowen.com


RE: SetVirtualDocumentRoot

Posted by "Plüm, Rüdiger, VF-Group" <ru...@vodafone.com>.
 

> -----Original Message-----
> From: Rich Bowen 
> To: dev@httpd.apache.org
> Subject: SetVirtualDocumentRoot
> 
> I was reading bug reports this morning, and wondered if 
> someone could  
> take a look at the patch offered here:
> 
> https://issues.apache.org/bugzilla/show_bug.cgi?id=26052#c19

The patch doesn't look appealing to me. Having a module changing the core config
on the fly always looks nasty to me, even more so if it stores data in the core config
structure that is allocated from a request pool. IMHO this is waiting for all
nasty things to happen, SEGFAULT at best.

Regards

Rüdiger



Re: SetVirtualDocumentRoot

Posted by Eric Covener <co...@gmail.com>.
On Wed, Nov 10, 2010 at 10:35 AM, Rich Bowen <rb...@rcbowen.com> wrote:
> I was reading bug reports this morning, and wondered if someone could take a
> look at the patch offered here:
>
> https://issues.apache.org/bugzilla/show_bug.cgi?id=26052#c19
>
> It adds a SetVirtualDocumentRoot configuration directive to mod_vhost_alias,
> making numerous third-party applications behave sanely when run under
> mod_vhost_alias.
>
> I've read the various justifications why we don't do this, and quite frankly
> I don't understand them. Is there a legitimate reason that setting
> DOCUMENT_ROOT on a per-dynamic-vhost basis is any different/worse than
> setting it on a per-regular-vhost basis? I don't understand the distinction,
> other than "we've never done it that way."

conceptually makes sense to me, at least in 2.3.x

--
Eric Covener
covener@gmail.com