You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by kloomis <kl...@it-resources.com> on 2005/10/07 00:16:18 UTC

[users@httpd] No Luck wuth VirtualHosts

Hello:

I'm having no luck with virtual hosts.

I have a domain name: myDomain.com and a sub-domain name: test.myDomain.com

I would like myDomain.com to go to /var/www/sites/prod and 
test.myDomain.com to go to /var/www/sites/dev

My hosts file reads: 127.0.0.1 myDomain.com localhost.localdomain localhost 
asus
(do I need a test.myDomain.com in here?)

My httpd.conf has this:

listen 80
ServerName myDomain.com:80
NameVirtualHost *:80
<VirtualHost *:80>
	DocumentRoot /var/www/sites/prod
	ServerName myDomain.com
</VirtualHost>

<VirtualHost *:80>
	DocumentRoot /var/www/sites/dev
	ServerName test.myDomain.com
</VirtualHost>

What happens is that either test.myDomain.com or myDomain.com go to the 
first VirtualHost whichever one I put first.

What am I missing?

Thanks,

Ken

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] No Luck wuth VirtualHosts

Posted by Joshua Slive <js...@gmail.com>.
On 10/6/05, Nick Jones <ni...@yahoo.com> wrote:
> > Both myDomain.com and test.myDomain.com point to the
> > IP address of my cable
> > modem. (They have real names I'm not showing here.)
> >
> > >Are you restarting the server after every change?
> >
> > Yes.
> >
> > Ken
>
> Ken,
>
> Try adding a "ServerAlias" directive to each of your
> vhost containers. So add:
>
> ServerAlias MyDomain.com (to the MyDomain vhost)
> ServerAlias test.MyDomain.com (to the test vhost)
>
> Then restart apache and see if that helps.

No, that shouldn't be necessary.

The most likely cause of this is that the cable modem is stripping (or
rewriting) the Host header and not simply forwarding packets.  That
means that apache doesn't have the information to do name-based
virtual hosting.  You can confirm that by logging the Host header in
the access log.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] No Luck wuth VirtualHosts

Posted by Krist van Besien <kr...@gmail.com>.
On 10/7/05, kloomis <kl...@it-resources.com> wrote:
>
> The most likely cause of this is that the cable modem is stripping (or
>  rewriting) the Host header and not simply forwarding packets.  That
>  means that apache doesn't have the information to do name-based
>  virtual hosting.  You can confirm that by logging the Host header in
>  the access log
>  OK, now the initial page is opening at the right directory, but all the
> follow on links are reverting to only one directory.  Could this be an
> Apache problem or is it my configs for the application I'm using?

That will probably be the application. Often you need to configure
somewhere what the base URL is that it is being served from.
Do the pages contain relative or absolute links?

Krist

--
krist.vanbesien@gmail.com
Solothurn, Switzerland

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] No Luck wuth VirtualHosts

Posted by kloomis <kl...@it-resources.com>.
At 05:27 PM 10/7/2005 +0200, you wrote:
>mod-rewrite does not touch anything going from your server to your
>client. If your clients get webpages with the wrong absolute url's in
>them, than this is because the webpages contain these absolute URLs,
>or the application generating the webpages generates these URLs.

Hmm.. Ok.  Thanks, Krist

Re: [users@httpd] No Luck wuth VirtualHosts

Posted by Krist van Besien <kr...@gmail.com>.
On 10/7/05, kloomis <kl...@it-resources.com> wrote:
>  At 01:09 PM 10/7/2005 +0200, you wrote:
>
> >  OK, now the initial page is opening at the right directory, but all the
>  > follow on links are reverting to only one directory.  Could this be an
>  > Apache problem or is it my configs for the application I'm using?
>
>  That will probably be the application. Often you need to configure
>  somewhere what the base URL is that it is being served from.
>  Do the pages contain relative or absolute links?
>  Yes, I do configure the base URLs, and I have set them up for each
> directory, but one keeps getting precedence.  The links are resolving to
> absolute URLs.  Could this be a mod-rewrite issue?

mod-rewrite does not touch anything going from your server to your
client. If your clients get webpages with the wrong absolute url's in
them, than this is because the webpages contain these absolute URLs,
or the application generating the webpages generates these URLs.

Krist
--
krist.vanbesien@gmail.com
Solothurn, Switzerland

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] No Luck wuth VirtualHosts

Posted by kloomis <kl...@it-resources.com>.
At 01:09 PM 10/7/2005 +0200, you wrote:
> >  OK, now the initial page is opening at the right directory, but all the
> > follow on links are reverting to only one directory.  Could this be an
> > Apache problem or is it my configs for the application I'm using?
>
>That will probably be the application. Often you need to configure
>somewhere what the base URL is that it is being served from.
>Do the pages contain relative or absolute links?

Yes, I do configure the base URLs, and I have set them up for each 
directory, but one keeps getting precedence.  The links are resolving to 
absolute URLs.  Could this be a mod-rewrite issue?

Ken




>Krist
>
>--
>krist.vanbesien@gmail.com
>Solothurn, Switzerland
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org

Re: [users@httpd] No Luck wuth VirtualHosts

Posted by kloomis <kl...@it-resources.com>.
>The most likely cause of this is that the cable modem is stripping (or
>rewriting) the Host header and not simply forwarding packets.  That
>means that apache doesn't have the information to do name-based
>virtual hosting.  You can confirm that by logging the Host header in
>the access log

OK, now the initial page is opening at the right directory, but all the 
follow on links are reverting to only one directory.  Could this be an 
Apache problem or is it my configs for the application I'm using?

Ken







Re: [users@httpd] No Luck wuth VirtualHosts

Posted by Nick Jones <ni...@yahoo.com>.

--- kloomis <kl...@it-resources.com> wrote:

> At 03:33 PM 10/6/2005 -0700, you wrote:
> >kloomis wrote:
> >>I'm having no luck with virtual hosts.
> >>My hosts file reads: 127.0.0.1 myDomain.com
> localhost.localdomain 
> >>localhost asus
> >>(do I need a test.myDomain.com in here?)
> >
> >Yes I believe you do.  Though it maybe should go
> through a DNS server, but 
> >this isn't a live domain.  So that will work.
> 
> Both myDomain.com and test.myDomain.com point to the
> IP address of my cable 
> modem. (They have real names I'm not showing here.)
> 
> >Are you restarting the server after every change?
> 
> Yes.
> 
> Ken

Ken,

Try adding a "ServerAlias" directive to each of your
vhost containers. So add:

ServerAlias MyDomain.com (to the MyDomain vhost)
ServerAlias test.MyDomain.com (to the test vhost)

Then restart apache and see if that helps.

Thanks
-Nick


		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] No Luck wuth VirtualHosts

Posted by kloomis <kl...@it-resources.com>.
At 03:33 PM 10/6/2005 -0700, you wrote:
>kloomis wrote:
>>I'm having no luck with virtual hosts.
>>My hosts file reads: 127.0.0.1 myDomain.com localhost.localdomain 
>>localhost asus
>>(do I need a test.myDomain.com in here?)
>
>Yes I believe you do.  Though it maybe should go through a DNS server, but 
>this isn't a live domain.  So that will work.

Both myDomain.com and test.myDomain.com point to the IP address of my cable 
modem. (They have real names I'm not showing here.)

>Are you restarting the server after every change?

Yes.

Ken

Re: [users@httpd] No Luck wuth VirtualHosts

Posted by Jessica Rasku <jr...@armispiansystems.ca>.
kloomis wrote:
> Hello:
> 
> I'm having no luck with virtual hosts.
> 
> I have a domain name: myDomain.com and a sub-domain name: test.myDomain.com
> 
> I would like myDomain.com to go to /var/www/sites/prod and 
> test.myDomain.com to go to /var/www/sites/dev
> 
> My hosts file reads: 127.0.0.1 myDomain.com localhost.localdomain 
> localhost asus
> (do I need a test.myDomain.com in here?)

Yes I believe you do.  Though it maybe should go through a DNS server, 
but this isn't a live domain.  So that will work.

> My httpd.conf has this:
> 
> listen 80
> ServerName myDomain.com:80
> NameVirtualHost *:80
> <VirtualHost *:80>
>     DocumentRoot /var/www/sites/prod
>     ServerName myDomain.com
> </VirtualHost>
> 
> <VirtualHost *:80>
>     DocumentRoot /var/www/sites/dev
>     ServerName test.myDomain.com
> </VirtualHost>
> 
> What happens is that either test.myDomain.com or myDomain.com go to the 
> first VirtualHost whichever one I put first.
> 
> What am I missing?

I'm not totally with it, though it should work from what I'm seeing 
there.  Are you restarting the server after every change?  Apache only 
reads the config file when it starts up, or when it recieves a SIGHUP (I 
think that's right).  So you need to be sure you're doing that.

						Jessica

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org