You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by M Busche <sp...@yahoo.com.INVALID> on 2014/08/06 11:20:26 UTC

[users@httpd] Order of applicatoin of sites-enabled configs

Hi,
I notice that the default virtual host configuration file name is 000-default.conf.  I presume the convention of starting virtual host configuration file names with a three digit number governs the order in which the configurations are applied.  Can someone point me to the apache docs web page that explains this?

Thanks,
Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Order of application of sites-enabled configs

Posted by Pete Houston <ph...@openstrike.co.uk>.
On Wed, Aug 06, 2014 at 02:20:26AM -0700, M Busche wrote:
> I notice that the default virtual host configuration file name is 000-default.conf.  I presume the convention of starting virtual host configuration file names with a three digit number governs the order in which the configurations are applied.  Can someone point me to the apache docs web page that explains this?

Yes, it's explained in
http://httpd.apache.org/docs/2.4/mod/core.html#include
which specifies (among other very useful information), "Shell-style
(fnmatch()) wildcard characters can be used in the filename or directory
parts of the path to include several files at once, in alphabetical
order."

HTH,

Pete
-- 
Openstrike - improving business through open source
http://www.openstrike.co.uk/ or call 01722 770036 / 07092 020107

Re: [users@httpd] Order of applicatoin of sites-enabled configs

Posted by Rich Bowen <rb...@rcbowen.com>.
On 08/07/2014 05:16 PM, M Busche wrote:
> Frank,
>
> I don't think you understood what I was trying to say.  My complaint 
> was that in the pre-packaged configuration made with the ubuntu 
> distribution, the default vhost configuration is placed in a file 
> prefixed with the string 000 which causes it to be loaded first.  I 
> renamed it to have a prefix 999, so that it was loaded (and processed) 
> last.

Note that 999 still comes before abc, so you might consider zzz instead 
of 999 in order to avoid the same surprise later.

>   I think we are in complete agreement.  My original query was to find 
> out whether there was something I was confused about, or alternatively 
> an explanation as to why-on-earth the people who put together the 
> ubuntu distribution would set things up that way.
>
>

The short answer is that Debian did this in order to make it easier to 
do stuff from the command line with the various utilities that they ship 
with their Apache httpd packages. The longer answer has to do with how 
good ideas mutate into complicated systems over the decades.

-- 
Rich Bowen - rbowen@rcbowen.com - @rbowen
http://apachecon.com/ - @apachecon


Re: [users@httpd] Order of applicatoin of sites-enabled configs

Posted by M Busche <sp...@yahoo.com.INVALID>.
Frank,

I don't think you understood what I was trying to say.  My complaint was that in the pre-packaged configuration made with the ubuntu distribution, the default vhost configuration is placed in a file prefixed with the string 000 which causes it to be loaded first.  I renamed it to have a prefix 999, so that it was loaded (and processed) last.  I think we are in complete agreement.  My original query was to find out whether there was something I was confused about, or alternatively an explanation as to why-on-earth the people who put together the ubuntu distribution would set things up that way.

Matt



On Thursday, August 7, 2014 3:40 AM, Francois Gingras <fr...@gmail.com> wrote:
 



Bad idea. Use the default vhost behaviour to define what vhost will
    be used for unknown hostnames not matching any ServerName /
    ServerAlias directive. The default *:80 vhost must be defined first.

You can even use ServerName <ip> or ServerName <random
    hostname> in the default vhost.

Frank




On Wed, Aug 6, 2014 at 11:58 AM, M Busche <sp...@yahoo.com.invalid> wrote:

Ooops!  Somehow I missed the "in alphabetical order" the first time I read that.  Thanks for making me read that again!
>
>After playing with this last night, it looks to me like Apache stops as soon as it finds a virtual host with a matching ServerName (or ServerAlias).  In my case I have two VirtualHosts the first for my official website name (ServerName www.mattbusche.org) and the second (my default) has no ServerName entry, but uses a "ServerAlias *" to match everything else and includes a Redirect www.mattbusche.org to send all requests through such non-standard names back to the official name for my website, www.mattbusche.org.  In that way requests to both mattbusche.org and 75.70.80.142 get directed back to www.mattbusche.org.  But to get it to work, I had to rename the default config so it was named alphabetically AFTER my main config.  For this reason I find the choice of numbering the default config with 000 strange, since you can't number anything before that, but (at least in my case and I would presume in most cases) you want a default to be chosen last. 
> I was getting an infinite redirect until I renamed the default configuration 999-default.conf.
>
>
>Here are my actual working conf files:
>
>100-www.mattbusche.org.conf:
>
><VirtualHost *:80>
>    ServerName www.mattbusche.org
>    ServerAdmin [my email address]
>    DocumentRoot /var/www
>    ErrorLog ${APACHE_LOG_DIR}/error.log
>    CustomLog ${APACHE_LOG_DIR}/access.log combined
></VirtualHost>
>
>
>999-default.conf:
>
><VirtualHost *:80>
>    ServerAlias *
>    Redirect permanent / http://www.mattbusche.org/
></VirtualHost>
>
>
>This is what worked for me.  Am I missing something?  Or am I using the system in dark and twisted ways that would make good church-going apache experts faint?
>
>
>BTW, I haven't made this change on my live server yet -- this is all on my test environment -- so don't be befuddled if you don't see my live machine redirecting as I claim here.
>
>
>Thanks,
>Matt
>
>
>
>
>
>On Wednesday, August 6, 2014 5:08 AM, Eric Covener <co...@gmail.com> wrote:
>On Wed, Aug 6, 2014 at 5:20 AM, M Busche <sp...@yahoo.com.invalid> wrote:
>
>
>
>> Hi,
>> I notice that the default virtual host configuration file name is 000-default.conf.  I presume the convention of starting virtual host configuration file names with a three digit number governs the order in which the configurations are applied.  Can someone point me to the apache docs web page that explains this?
>>
>
>This is a layout determined by whoever packaged your server and
>created your default configuration. Check out their README.  It just
>boils down to the Include directive:
>http://httpd.apache.org/docs/2.2/mod/core.html#include
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Order of applicatoin of sites-enabled configs

Posted by Francois Gingras <fr...@gmail.com>.
Bad idea. Use the default vhost behaviour to define what vhost will be used
for unknown hostnames not matching any ServerName / ServerAlias directive.
The default *:80 vhost must be defined first.

You can even use ServerName <ip> or ServerName <random hostname> in the
default vhost.

Frank


On Wed, Aug 6, 2014 at 11:58 AM, M Busche <sp...@yahoo.com.invalid>
wrote:

> Ooops!  Somehow I missed the "in alphabetical order" the first time I read
> that.  Thanks for making me read that again!
>
> After playing with this last night, it looks to me like Apache stops as
> soon as it finds a virtual host with a matching ServerName (or
> ServerAlias).  In my case I have two VirtualHosts the first for my official
> website name (ServerName www.mattbusche.org) and the second (my default)
> has no ServerName entry, but uses a "ServerAlias *" to match everything
> else and includes a Redirect www.mattbusche.org to send all requests
> through such non-standard names back to the official name for my website,
> www.mattbusche.org.  In that way requests to both mattbusche.org and
> 75.70.80.142 get directed back to www.mattbusche.org.  But to get it to
> work, I had to rename the default config so it was named alphabetically
> AFTER my main config.  For this reason I find the choice of numbering the
> default config with 000 strange, since you can't number anything before
> that, but (at least in my case and I would presume in most cases) you want
> a default to be chosen last.
>  I was getting an infinite redirect until I renamed the default
> configuration 999-default.conf.
>
>
> Here are my actual working conf files:
>
> 100-www.mattbusche.org.conf:
>
> <VirtualHost *:80>
>     ServerName www.mattbusche.org
>     ServerAdmin [my email address]
>     DocumentRoot /var/www
>     ErrorLog ${APACHE_LOG_DIR}/error.log
>     CustomLog ${APACHE_LOG_DIR}/access.log combined
> </VirtualHost>
>
>
> 999-default.conf:
>
> <VirtualHost *:80>
>     ServerAlias *
>     Redirect permanent / http://www.mattbusche.org/
> </VirtualHost>
>
>
> This is what worked for me.  Am I missing something?  Or am I using the
> system in dark and twisted ways that would make good church-going apache
> experts faint?
>
>
> BTW, I haven't made this change on my live server yet -- this is all on my
> test environment -- so don't be befuddled if you don't see my live machine
> redirecting as I claim here.
>
>
> Thanks,
> Matt
>
>
>
>
> On Wednesday, August 6, 2014 5:08 AM, Eric Covener <co...@gmail.com>
> wrote:
> On Wed, Aug 6, 2014 at 5:20 AM, M Busche <sp...@yahoo.com.invalid>
> wrote:
>
>
>
> > Hi,
> > I notice that the default virtual host configuration file name is
> 000-default.conf.  I presume the convention of starting virtual host
> configuration file names with a three digit number governs the order in
> which the configurations are applied.  Can someone point me to the apache
> docs web page that explains this?
> >
>
> This is a layout determined by whoever packaged your server and
> created your default configuration. Check out their README.  It just
> boils down to the Include directive:
> http://httpd.apache.org/docs/2.2/mod/core.html#include
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Order of applicatoin of sites-enabled configs

Posted by M Busche <sp...@yahoo.com.INVALID>.
Ooops!  Somehow I missed the "in alphabetical order" the first time I read that.  Thanks for making me read that again!

After playing with this last night, it looks to me like Apache stops as soon as it finds a virtual host with a matching ServerName (or ServerAlias).  In my case I have two VirtualHosts the first for my official website name (ServerName www.mattbusche.org) and the second (my default) has no ServerName entry, but uses a "ServerAlias *" to match everything else and includes a Redirect www.mattbusche.org to send all requests through such non-standard names back to the official name for my website, www.mattbusche.org.  In that way requests to both mattbusche.org and 75.70.80.142 get directed back to www.mattbusche.org.  But to get it to work, I had to rename the default config so it was named alphabetically AFTER my main config.  For this reason I find the choice of numbering the default config with 000 strange, since you can't number anything before that, but (at least in my case and I would presume in most cases) you want a default to be chosen last. 
 I was getting an infinite redirect until I renamed the default configuration 999-default.conf.


Here are my actual working conf files:

100-www.mattbusche.org.conf:

<VirtualHost *:80>
    ServerName www.mattbusche.org
    ServerAdmin [my email address]
    DocumentRoot /var/www
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


999-default.conf:

<VirtualHost *:80>
    ServerAlias *
    Redirect permanent / http://www.mattbusche.org/
</VirtualHost>


This is what worked for me.  Am I missing something?  Or am I using the system in dark and twisted ways that would make good church-going apache experts faint?


BTW, I haven't made this change on my live server yet -- this is all on my test environment -- so don't be befuddled if you don't see my live machine redirecting as I claim here.


Thanks,
Matt




On Wednesday, August 6, 2014 5:08 AM, Eric Covener <co...@gmail.com> wrote:
On Wed, Aug 6, 2014 at 5:20 AM, M Busche <sp...@yahoo.com.invalid> wrote:



> Hi,
> I notice that the default virtual host configuration file name is 000-default.conf.  I presume the convention of starting virtual host configuration file names with a three digit number governs the order in which the configurations are applied.  Can someone point me to the apache docs web page that explains this?
>

This is a layout determined by whoever packaged your server and
created your default configuration. Check out their README.  It just
boils down to the Include directive:
http://httpd.apache.org/docs/2.2/mod/core.html#include 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Order of applicatoin of sites-enabled configs

Posted by Eric Covener <co...@gmail.com>.
On Wed, Aug 6, 2014 at 5:20 AM, M Busche <sp...@yahoo.com.invalid> wrote:
> Hi,
> I notice that the default virtual host configuration file name is 000-default.conf.  I presume the convention of starting virtual host configuration file names with a three digit number governs the order in which the configurations are applied.  Can someone point me to the apache docs web page that explains this?
>

This is a layout determined by whoever packaged your server and
created your default configuration. Check out their README.  It just
boils down to the Include directive:
http://httpd.apache.org/docs/2.2/mod/core.html#include

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org