Forum Moderators: phranque
Two FQDN's;
http://www.example2.com
and
http://www.example.com
I want to VirtualHost from the one server.
Here is my httpd.conf:
ServerName 192.***.***.***:80
UseCanonicalName On
NameVirtualHost 192.***.***.***:80
<VirtualHost www.example.com:80>
ServerName www.example.com
ServerAlias example.com *.example.com
DocumentRoot /home/jail/home/example/html
ServerAdmin admin@example.com
</VirtualHost>
<VirtualHost www.example2.com:80>
ServerName www.example2.com
ServerAlias example2.com *.example2.com
DocumentRoot /var/www/html
ServerAdmin admin@example2.com
</VirtualHost>
The output of "apachectl -t -D DUMP_VHOSTS" is
VirtualHost configuration:
192.***.***.***:80 is a NameVirtualHost
default server www.example.com (/etc/httpd/conf/httpd.conf:1095)
port 80 namevhost www.example.com (/etc/httpd/conf/httpd.conf:1095)
port 80 namevhost www.example2.com (/etc/httpd/conf/httpd.conf:1103)
wildcard NameVirtualHosts and _default_ servers:
_default_:443 new.host.name (/etc/httpd/conf.d/ssl.conf:90)
Syntax OK
The output of the DNS lookup seems right:
<snip>
When you got to http://www.example.com you go right to what http://www.example2.com is.
If you goto http://www.example2.com/~example you get what http://www.example.com *should* be
-- but the URL goes to: http://192.***.***.***/~example/forum/index.php
Can someone help me find what is missing? Or what I am doing wrong?
TIA
[edited by: jdMorgan at 6:30 pm (utc) on Sep. 10, 2004]
[edit reason] Removed specifics. Please see TOS. [/edit]
So I'd change it as follows:
Port 80
[i]# OR[/i]
Listen 192.168.0.1:80
[small]# Use Port 80 if you don't use SSL, otherwise you need several Listen directives[/small]ServerName www.mydomain.com
UseCanonicalName On
NameVirtualHost 192.168.0.1:80
<VirtualHost 192.168.0.1:80>
ServerName www.example.com
ServerAlias example.com sub.example.com
DocumentRoot /home/jail/home/example/html
ServerAdmin admin@example.com
</VirtualHost>
<VirtualHost 192.168.0.1:80>
ServerName www.example2.com
ServerAlias example2.com sub.example2.com
DocumentRoot /var/www/html
ServerAdmin admin@example2.com
</VirtualHost>
ServerName www.example.com
UseCanonicalName On
NameVirtualHost 192.168.0.1:80
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 192.168.0.1:80>
ServerName www.example2.com
DocumentRoot /home/jail/home/example/html
</VirtualHost>
----------------------------------------
This is what I have for bare simplicity.
I have <VitualHost *:80> for the catch all default. Everything in -D DUMP_VHOSTS looks fine. Status OK.
www.example.com - works
www.example2.com - works exactly like www.example.com
www.example.com/~user1 == www.example2.com/~user1
It seems as if the DocumentRoot is not being read.
The correct ServerName is in the address bar, but it is not "taking on" the document root.
The said changes did have a positive impact... but I am not "there" yet.
Any suggestions?
NameVirtualHost *:80
<VirtualHost 192.168.0.1:80>
ServerName www.example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 192.168.0.1:80>
ServerName www.example2.com
DocumentRoot /home/jail/home/example/html
</VirtualHost>
case: when using "NameVirtualHost *:80" -t -D DUMP_VHOSTS gives:
[warn] VirtualHost 192.168.0.1:80 overlaps with 192.168.0.1, perhaps you need a VirtualHost directive
/usr/sbin.apachectl: line 83: 5858 Segmentation fault $HTTPD $ARGV
and
NameVirtualHost 192.168.0.1:80
<VirtualHost 192.168.0.1:80>
ServerName www.example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 192.168.0.1:80>
ServerName www.example2.com
DocumentRoot /home/jail/home/example/html
</VirtualHost>
case: when using "NameVirtualHost 192.168.0.1:80" -t -D DUMP_VHOSTS gives:
192.168.1.1:80 is a NameVirtualHost
default server is www.example.com
port 80 namevhost www.example.com
port 80 namevhost www.example2.com
wildcard NameVirtualhost and _default_ servers:
_default_:443 new.host.name
So, only going with the second config from here....
when NameVirtualHost 192.168.0.1 is used (everything is exactly like the second config.)
NameVirtualHost 192.168.0.1:80
<VirtualHost 192.168.0.1:80>
ServerName www.example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 192.168.0.1:80>
ServerName www.example2.com
DocumentRoot /home/jail/home/example/html
</VirtualHost>
It occured to me that the header MUST be getting stripped. Because www.example.com == www.example2.com
When I make www.example2.com the default by wildcard is still get www.example2.com == www.example.com
www.example2.com goes to the DocumentRoot of /home/jail/home/example2/
but so does www.example.com -- which is the same problem I had before; only reversed Servername.
The oddity is that /~user1/ works in for both www.example.com and www.example2.com. logically www.example2.com should not have any users. This just brings home that www.example.com and www.example2.com are equal. I put in a UserDir in the VirtualHost container for www.example2.com as
UserDir someotherdir_thatdoesnotexist Therefore, I believe the Servername directive in the VirtualHost block is not being matched to the browser provided ServerName.
More detail:
I am using a LinkSys router and port forwarding 80 to the linux/apache machine. I tried DMZ'ing that machine and unport forwrding and all the results were the same.
I hope this helps. George please stay with me.
(again just to be clear I am using the config exactly as above... I mentioned a lot of changes and testing.... But, I put it all back to that one above. I believe that is the a version that will work after we find out why the browser ServerName is not matching with the container ServerName)
It was because of the NAT of the firewall.
Here is my config file:
------------------------------------------------
ServerName localhost
UseCanonicalName On
NameVirtualHost 192.168.0.1 #external address
NameVirtualHost 192.168.1.100 #internal address
<VirtualHost 192.168.1.100 192.168.0.1>
ServerName www.example.com
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost 192.168.1.100 192.168.0.1>
ServerName www.example2.com
DocumentRoot /home/jail/home/example/html
</VirtualHost>
------------------------------------------------
I did not recompile of anything.. I just used the config from above. (and restarted apache)
My router is set up to port forward. To the ...100 box.
I am set thanks for all the help.