Results 1 to 9 of 9
I am attempting to set up virtual name based hosting with Apache,and Red Hat 9
My problem is that the server always defaults to the first host. /var/www/ausbec.
Sorry for ...
- 10-26-2004 #1Just Joined!
- Join Date
- Oct 2004
- Posts
- 5
Virtual hosting
I am attempting to set up virtual name based hosting with Apache,and Red Hat 9
My problem is that the server always defaults to the first host. /var/www/ausbec.
Sorry for the big code post but i thought it would help.
Code:# Use name-based virtual hosting. # NameVirtualHost *:80 <VirtualHost *:80> ServerName www.ausbec.com DocumentRoot /var/www/ausbec DirectoryIndex index.html index.php index.htm </VirtualHost> <VirtualHost *:80> ServerName www.adsolutions.com.au DocumentRoot /var/www/adsolutions DirectoryIndex index.html </VirtualHost> # Where do we put the lock and pif files? LockFile "/var/lock/httpd.lock" CoreDumpDirectory "/etc/httpd" # Defaults for virtual hosts # Logs # # Virtual hosts # # Virtual host Default Virtual Host <VirtualHost *> ServerSignature email DirectoryIndex index.php index.html index.htm index.shtml LogLevel warn HostNameLookups off </VirtualHost>
- 10-26-2004 #2
Re: Virtual hosting
try this, notice the part in bold, change to your real ip
its probably also a good idea to specify a different log file for each VH within the <virtuahost> container</virtualhost>
# Use name-based virtual hosting.
#
NameVirtualHost 192.168.1.1:80
<VirtualHost *:80>
ServerName www.ausbec.com
DocumentRoot /var/www/ausbec
DirectoryIndex index.html index.php index.htm
</VirtualHost>
<VirtualHost *:80>
ServerName www.adsolutions.com.au
DocumentRoot /var/www/adsolutions
DirectoryIndex index.html
</VirtualHost>
# Where do we put the lock and pif files?
LockFile "/var/lock/httpd.lock"
CoreDumpDirectory "/etc/httpd"
# Defaults for virtual hosts
# Logs
#
# Virtual hosts
#
# Virtual host Default Virtual Host
<VirtualHost *>
ServerSignature email
DirectoryIndex index.php index.html index.htm index.shtml
LogLevel warn
HostNameLookups off
</VirtualHost>
- 10-26-2004 #3Linux User
- Join Date
- Oct 2004
- Location
- /dev/random
- Posts
- 404
Well, that is not needed; but it gives you a tighter binding if you use something like that.
You can explicitly control the interfaces to which a VH could be bound.
And yes, it would definitely help to have different log files for individual VHs.
My guess for the problem is that both the dirs contain the same index.html, so, you're not able to notice the difference.
Is it so?
One more wild guess would be missing <Directorty ...>....</Directory> containers for the docroots of individual VHs.
If not, could you please post the way you're trying to access the sites?
Also, are the domain names properly resolved?The Unforgiven
Registered Linux User #358564
- 10-27-2004 #4Just Joined!
- Join Date
- Oct 2004
- Posts
- 5
Hi,
Thanks for your responses.
I am definately serving different content from each folder.
the adsolutions folder is a test page, and the ausbec folder is a php website.
I am not sure about the directory containers as I have not set any. I have attempted to find information about it on the net, it seems that it is not needed in a simple setup to make it work. But I may have misunderstood,(newbie
) .
The domain names are resolved using a DNS server, both www.ausbec.com and www.adsolutions.com.au are accessible from the internet, and resolve to the same IP address.
As a further point, if I change the DocumentRoot directive in the ausbec.com virtual host container, the path does change and both VHs resolve to the new path. So it seems that the first directive is working and the second is not, so Apache resolves to the primary Host.
Let me know if you require further information.
Thanks.
- 10-27-2004 #5Linux User
- Join Date
- Oct 2004
- Location
- /dev/random
- Posts
- 404
Yes, agreed...I am definately serving different content from each folder.
This is what it appears to be; but some small detail you might have overlooked?
Besides, it would be easier if you could set up individual log files for both the VHs and track what is happening - where does it get mapped.The Unforgiven
Registered Linux User #358564
- 10-27-2004 #6Just Joined!
- Join Date
- Oct 2004
- Posts
- 5
I have set seperate logs
The ausbec access log follows(after accessing both hosts once)Code:NameVirtualHost *:80 <VirtualHost *:80> ServerName www.ausbec.com DocumentRoot /var/www/ausbec serverpath /ausbec/ ErrorLog /var/log/ausbec_error.log TransferLog /var/log/ausbec_access.log DirectoryIndex index.html index.php index.html </VirtualHost> <VirtualHost *:80> ServerName www.adsolutions.com.au DocumentRoot /var/www/adsolutions ServerPath /adsolutions/ ErrorLog /var/log/solutions_error.log TransferLog /var/log/solutions_access.log DirectoryIndex index.html index.php index.htm </VirtualHost>
The Splash1.swf is the opening for the webpage.Code:203.113.236.190 - - [27/Oct/2004:21:29:26 +091800] "GET / HTTP/1.1" 200 1808 203.113.236.190 - - [27/Oct/2004:21:29:26 +091800] "GET /Splash1.swf HTTP/1.1" 304 0 203.113.236.190 - - [27/Oct/2004:21:29:33 +091800] "GET / HTTP/1.1" 304 0 203.113.236.190 - - [27/Oct/2004:21:29:33 +091800] "GET /Splash1.swf HTTP/1.1" 304 0
The error log for ausbec is empty as are bothe the adsolution log files.
I feel there must be something simple that I have overlooked.
also note that the DNS server is on a seperate machine within my network.(but I don't think this should make a differance)
Another thing I tried was to comment out the first VH container,(ausbec.com). the server then served the page from adsolutions.com.au to both domains.
- 10-27-2004 #7
well, doesn't seem you like my advice so here is my working VH section with fake url and ip's so do what you will with it.
but mine is working
Code:NameVirtualHost 192.168.1.1 <VirtualHost bugzilla.yourhost.com> ServerAdmin webmaster@dummy-host.com DocumentRoot /usr/local/apache2/htdocs/bugs ServerName bugzilla.yourhost.com ErrorLog logs/testbugs_error_log CustomLog logs/testbugs_access_log common </VirtualHost> <VirtualHost developer.yourhost.com> ServerAdmin webmaster@dummy-host.com DocumentRoot /usr/local/apache2/htdocs ServerName developer.yourhost.com ErrorLog logs/testwas_error_log CustomLog logs/testwas_access_log common </VirtualHost>
- 10-27-2004 #8Linux Enthusiast
- Join Date
- Jun 2002
- Location
- San Antonio
- Posts
- 621
The issue is, his should work the way it is :-/ Check the full httpd.conf for other instances of NameVirtualHost. When you stop/start apache is there an error like "mixing * and non-* ports . . . "?
Also of note is the fact that one returns a 200 code, while the other returns a 304. Try to telnet to port 80, to see what the 304 code redirects to. Something like:
Remember, there should be two enters required after the Host: directive.Code:$ telnet 192.168.1.1 80 GET / HTTP/1.1 Host: www.adsolutions.com.au
Best,
SamuelI respectfully decline the invitation to join your delusion.
- 10-28-2004 #9Just Joined!
- Join Date
- Oct 2004
- Posts
- 5
Thanks Thanks Thanks
I removed the "Virtual Host Default Virtual Host" directives and now it all works.Code:Check the full httpd.conf for other instances of NameVirtualHost
jledhead: Thanks for your advise, I did try what you suggested but was still having problems.
Thanks to all that helped.


Reply With Quote
