apache httpd.conf servername overiding virtualhost setting of the same?

apache httpd.conf servername overiding virtualhost setting of the same?

Post by Glenn Huthe » Tue, 12 Jun 2001 00:43:00



Hi All

I don't know if I even asked that question in a way that makes sense - I'm
still learning! :)

The following is happening (I have a virtualserver):

I've two domains, eg:
domain1.com
domain2.com

I want to direct the two domains to:
blah/htdocs/domain1
blah/htdocs/domain2

I have VirtualHost entries for each domain like this:
<VirtualHost domain1.com www.domain1.com>
DocumentRoot /usr/local/etc/httpd/htdocs/domain1
ServerName domain1.com
</VirtualHost>
<VirtualHost domain2.com www.domain2.com>
DocumentRoot /usr/local/etc/httpd/htdocs/domain2
ServerName domain2.com
</VirtualHost>

domain2.com  OR domain1.com always points to /htdocs

...apparently dependant on these entries within the httpd.conf
ServerName domain1.com.au
ServerRoot /usr/local/etc/httpd

With the above configuration this is the way things would be pointed:
http://domain1.com -> /htdocs
http://www.domain1.com -> /htdocs/domain1
http://domain2.com -> /htdocs/domain2
http://www.domain2.com -> /htdocs/domain2

But if I change ServerName domain1.com.au to be ServerName domain2.com.au
this is what happens:
http://domain1.com -> /htdocs/domain1
http://www.domain1.com -> /htdocs/domain1
http://domain2.com -> /htdocs
http://www.domain2.com -> /htdocs/domain2

Those are the details. The question is this. HOW can I have the httpd.conf
direct the two domains to their respective subdirectories, WITHOUT having
this over-ruling happening? Deleting the Servername setting doesn't seem to
work - somehow the server seems still knows what it's main domain is.

Please help!

Glenn
--
----
email replies to ghuth.geo at yahoo.com (i.e. Remove "SPAMBLOCK" from email
address )

 
 
 

apache httpd.conf servername overiding virtualhost setting of the same?

Post by David Efflan » Tue, 12 Jun 2001 01:40:27



> I don't know if I even asked that question in a way that makes sense - I'm
> still learning! :)

> The following is happening (I have a virtualserver):

> I've two domains, eg:
> domain1.com
> domain2.com

> I want to direct the two domains to:
> blah/htdocs/domain1
> blah/htdocs/domain2

> I have VirtualHost entries for each domain like this:
><VirtualHost domain1.com www.domain1.com>
> DocumentRoot /usr/local/etc/httpd/htdocs/domain1
> ServerName domain1.com
></VirtualHost>
><VirtualHost domain2.com www.domain2.com>
> DocumentRoot /usr/local/etc/httpd/htdocs/domain2
> ServerName domain2.com
></VirtualHost>
(snip)
> Glenn
> --
> ----
> email replies to ghuth.geo at yahoo.com (i.e. Remove "SPAMBLOCK" from email
> address )

Which apache version?  You may be missing something.  Read the following,
follow its directions (especially NameVirtualHost and ServerAlias) and
then come back if you have questions:

http://httpd.apache.org/docs/vhosts/name-based.html
http://httpd.apache.org/docs/vhosts/index.html

PS: your subject line is too long.

--
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/

 
 
 

apache httpd.conf servername overiding virtualhost setting of the same?

Post by Glenn Huthe » Tue, 12 Jun 2001 02:30:04




> > I don't know if I even asked that question in a way that makes sense -
I'm
> > still learning! :)

> > The following is happening (I have a virtualserver):

> > I've two domains, eg:
> > domain1.com
> > domain2.com

> > I want to direct the two domains to:
> > blah/htdocs/domain1
> > blah/htdocs/domain2

> > I have VirtualHost entries for each domain like this:
> ><VirtualHost domain1.com www.domain1.com>
> > DocumentRoot /usr/local/etc/httpd/htdocs/domain1
> > ServerName domain1.com
> ></VirtualHost>
> ><VirtualHost domain2.com www.domain2.com>
> > DocumentRoot /usr/local/etc/httpd/htdocs/domain2
> > ServerName domain2.com
> ></VirtualHost>
> (snip)
> > Glenn
> > --
> > ----
> > email replies to ghuth.geo at yahoo.com (i.e. Remove "SPAMBLOCK" from
email
> > address )

> Which apache version?  You may be missing something.  Read the following,
> follow its directions (especially NameVirtualHost and ServerAlias) and
> then come back if you have questions:

Remember I'm an amatuer using a preconfigured virtual server :) I check the
httpd.conf file and it says up the top that Apache 1.3 is what I'm using. As
for the links below - I had already scoured them completely for the answers.
What I found had me believe that it should be working the way I want it
too - both virtmaps properly pointing and not being overruled by the
main_server. The only thing close I could find was:

"The main_server is only used to serve a request if the IP address and port
number to which the client connected is unspecified and does not match any
other vhost (including a _default_ vhost). In other words the main_server
only catches a request for an unspecified address/port combination (unless
there is a _default_ vhost which matches that port)."

However, my NameVirtualHost setting is this - "NameVirtualHost
111.22.33.44:*" which means all ports, thus the main_server should not
"serve a request", as the request DOES match an "other vhost".

Can anyone clarify "unless there is a _default_ vhost which matches that
port"?  Does this mean that there is an exception to the rule? THAT's where
I think the problem lies.

But the thing is, with or without a _default_ vhost, the main_server still
seems to be serving requests covered in the <VirtualHost>s.

Quote:> http://httpd.apache.org/docs/vhosts/name-based.html
> http://httpd.apache.org/docs/vhosts/index.html

> PS: your subject line is too long.

Sorry - guess we're stuck with it now :) I couldn't think how to write all
the details in a shorter question.

Glenn

 
 
 

apache httpd.conf servername overiding virtualhost setting of the same?

Post by David Efflan » Wed, 13 Jun 2001 09:17:38






>> > I don't know if I even asked that question in a way that makes sense -
> I'm
>> > still learning! :)

>> > The following is happening (I have a virtualserver):

>> > I've two domains, eg:
>> > domain1.com
>> > domain2.com

>> > I want to direct the two domains to:
>> > blah/htdocs/domain1
>> > blah/htdocs/domain2

Try using an IP instead of hostname list (which did not seem to work for
met in apache 1.3), then use <ServerAlias> for alternate server names.

- Show quoted text -

Quote:>> > I have VirtualHost entries for each domain like this:
>> ><VirtualHost domain1.com www.domain1.com>
>> > DocumentRoot /usr/local/etc/httpd/htdocs/domain1
>> > ServerName domain1.com
>> ></VirtualHost>
>> ><VirtualHost domain2.com www.domain2.com>
>> > DocumentRoot /usr/local/etc/httpd/htdocs/domain2
>> > ServerName domain2.com
>> ></VirtualHost>
>> (snip)
>> > Glenn
>> > --
>> > ----
>> > email replies to ghuth.geo at yahoo.com (i.e. Remove "SPAMBLOCK" from
> email
>> > address )

>> Which apache version?  You may be missing something.  Read the following,
>> follow its directions (especially NameVirtualHost and ServerAlias) and
>> then come back if you have questions:

> Remember I'm an amatuer using a preconfigured virtual server :) I check the
> httpd.conf file and it says up the top that Apache 1.3 is what I'm using. As
> for the links below - I had already scoured them completely for the answers.
> What I found had me believe that it should be working the way I want it
> too - both virtmaps properly pointing and not being overruled by the
> main_server. The only thing close I could find was:

> "The main_server is only used to serve a request if the IP address and port
> number to which the client connected is unspecified and does not match any
> other vhost (including a _default_ vhost). In other words the main_server
> only catches a request for an unspecified address/port combination (unless
> there is a _default_ vhost which matches that port)."

> However, my NameVirtualHost setting is this - "NameVirtualHost
> 111.22.33.44:*" which means all ports, thus the main_server should not
> "serve a request", as the request DOES match an "other vhost".

I don't really think you need the :* unless you have apache set to listen
to ports other than the default port 80 (or maybe SSL which uses 443).

Quote:> Can anyone clarify "unless there is a _default_ vhost which matches that
> port"?  Does this mean that there is an exception to the rule? THAT's where
> I think the problem lies.

If you have a 'listen' directive for anything other than a port, comment
it out.

Quote:> But the thing is, with or without a _default_ vhost, the main_server still
> seems to be serving requests covered in the <VirtualHost>s.

Do any of the names match a different IP in /etc/hosts or DNS than your
NameVirtualHost IP?

--
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/

 
 
 

apache httpd.conf servername overiding virtualhost setting of the same?

Post by Glenn Huthe » Wed, 13 Jun 2001 22:49:18







> >> > I don't know if I even asked that question in a way that makes
sense -
> > I'm
> >> > still learning! :)

> >> > The following is happening (I have a virtualserver):

> >> > I've two domains, eg:
> >> > domain1.com
> >> > domain2.com

> >> > I want to direct the two domains to:
> >> > blah/htdocs/domain1
> >> > blah/htdocs/domain2

> Try using an IP instead of hostname list (which did not seem to work for
> met in apache 1.3), then use <ServerAlias> for alternate server names.

So we're talking:

<VirtualHost 111.222.333.444>
DocumentRoot /usr/local/etc/httpd/htdocs/domain1
# ServerName domain1.com
ServerAlias domain1.com www.domain1.com
</VirtualHost>

Correct? Still does the same thing. Funny also, if I change the ServerName
of the main_server, Whatever is listed in the ServerAlias of the VirtualHost
actually SWAPS! This proves (I think) that the Main_Server is overriding the
VirtualHost, and that the VirtualHost is setup correctly.

But remove the DocumentRoot /usr/local/etc/httpd/htdocs and it still knows
of this directory. SOMETHING must be point there....

- Show quoted text -

Quote:> >> > I have VirtualHost entries for each domain like this:
> >> ><VirtualHost domain1.com www.domain1.com>
> >> > DocumentRoot /usr/local/etc/httpd/htdocs/domain1
> >> > ServerName domain1.com
> >> ></VirtualHost>
> >> ><VirtualHost domain2.com www.domain2.com>
> >> > DocumentRoot /usr/local/etc/httpd/htdocs/domain2
> >> > ServerName domain2.com
> >> ></VirtualHost>
> >> (snip)
> >> > Glenn
> >> > --
> >> > ----
> >> > email replies to ghuth.geo at yahoo.com (i.e. Remove "SPAMBLOCK" from
> > email
> >> > address )

> >> Which apache version?  You may be missing something.  Read the
following,
> >> follow its directions (especially NameVirtualHost and ServerAlias) and
> >> then come back if you have questions:

> > Remember I'm an amatuer using a preconfigured virtual server :) I check
the
> > httpd.conf file and it says up the top that Apache 1.3 is what I'm
using. As
> > for the links below - I had already scoured them completely for the
answers.
> > What I found had me believe that it should be working the way I want it
> > too - both virtmaps properly pointing and not being overruled by the
> > main_server. The only thing close I could find was:

> > "The main_server is only used to serve a request if the IP address and
port
> > number to which the client connected is unspecified and does not match
any
> > other vhost (including a _default_ vhost). In other words the
main_server
> > only catches a request for an unspecified address/port combination
(unless
> > there is a _default_ vhost which matches that port)."

> > However, my NameVirtualHost setting is this - "NameVirtualHost
> > 111.22.33.44:*" which means all ports, thus the main_server should not
> > "serve a request", as the request DOES match an "other vhost".

> I don't really think you need the :* unless you have apache set to listen
> to ports other than the default port 80 (or maybe SSL which uses 443).

I will have SSL enabled. The server came preoconfigured with the :* so I'm
not to worried... should I be?

Quote:> > Can anyone clarify "unless there is a _default_ vhost which matches that
> > port"?  Does this mean that there is an exception to the rule? THAT's
where
> > I think the problem lies.

> If you have a 'listen' directive for anything other than a port, comment
> it out.

I don't even know what you mean... but there's no mention of "listen" in the
httpd.conf

And I now know what a _default_ vhost does too... So that answers this
particular question. "Any vhost that includes the magic _default_ wildcard
is given the same ServerName as the main_server. " (And my _default_ is
pointing to htdocs/domain1.com so that's not it either).

Quote:> > But the thing is, with or without a _default_ vhost, the main_server
still
> > seems to be serving requests covered in the <VirtualHost>s.

> Do any of the names match a different IP in /etc/hosts or DNS than your
> NameVirtualHost IP?

Hmm ok - The only file I have is called "local-host-names" and contains
nothing except for this text - "domain1.com". I don't even know what this
file does...

No hosts file... I'm using FreeBSD it that matters.

Thanks, G

Glenn

 
 
 

1. httpd.conf servername overiding virtualhost setting of the same

Hi All

I don't know if I even asked that question in a way that makes sense - I'm
still learning! :) It may even be an Apache problem now that I think of it,
but if anyone can shed light, that'd be fantastic!

The following is happening (I have a virtualserver):

I've two domains, eg:
domain1.com
domain2.com

I want to direct the two domains to:
blah/htdocs/domain1
blah/htdocs/domain2

I have VirtualHost entries for each domain like this:
<VirtualHost domain1.com www.domain1.com>
DocumentRoot /usr/local/etc/httpd/htdocs/domain1
ServerName domain1.com
</VirtualHost>
<VirtualHost domain2.com www.domain2.com>
DocumentRoot /usr/local/etc/httpd/htdocs/domain2
ServerName domain2.com
</VirtualHost>

domain2.com  OR domain1.com always points to /htdocs

Apparently dependant on these entries within the httpd.conf
ServerName domain1.com.au
ServerRoot /usr/local/etc/httpd

With the above configuration this is the way things would be pointed:
http://domain1.com -> /htdocs
http://www.domain1.com -> /htdocs/domain1
http://domain2.com -> /htdocs/domain2
http://www.domain2.com -> /htdocs/domain2

But if I change ServerName domain1.com.au to be ServerName domain2.com.au
this is what happens:
http://domain1.com -> /htdocs/domain1
http://www.domain1.com -> /htdocs/domain1
http://domain2.com -> /htdocs
http://www.domain2.com -> /htdocs/domain2

Those are the details. The question is this. HOW can I have the httpd.conf
direct the two domains to their respective subdirectories, WITHOUT having
this over-ruling happening? Deleting the Servername setting doesn't seem to
work - somehow the server seems to remember what I last told it.

Please help!

Glenn
--
----
email replies to ghuth.geo at yahoo.com (i.e. Remove "SPAMBLOCK" from email
address )

2. continuing a paused process

3. Default httpd.conf says Expected </VirtualHost> but saw </VirtualHost>

4. Linux screen color.

5. Apache: User/Group directive in plain httpd.conf and VirtualHost

6. Can't ping one way (Linux-WinME)

7. apache httpd.conf VirtualHost: last entry overrides all others

8. AIX sendmail configuration

9. Apache: Problem with 1.3.3: ServerName is ignored and a VirtualHost is sent

10. Test httpd.conf setup - using variables in httpd.conf

11. apache httpd.conf setting question

12. translator from CERN httpd configuration rules to Apache httpd conf?

13. APACHE 1.1.1 httpd.conf and the "httpd -f ..." option