Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Virtual Host problem

Status
Not open for further replies.

Faustus67

Programmer
Dec 10, 2003
5
GB
Hello,

I apologise in advance if this is a stupid question, I am a newbe
with both Linux and Apache.
I am unable to configure Apache to use virtual hosts under Fedora.

httpd -S gives the following:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server (/usr/local/apache2/conf/httpd
port 80 namevhost (/usr/local/apache2/conf/ht
port 80 namevhost (/usr/local/apache2/conf
Syntax OK


The virtual host section of httpd.conf is:

NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#

# As this host is listed first, it is the default
<VirtualHost *:80>
ServerName ServerAdmin drder@robertsontheweb.co.uk
DocumentRoot /#ServerAlias robertsontheweb.co.uk *.robertsontheweb.co.uk
</VirtualHost>

<VirtualHost *:80>
ServerName DocumentRoot /#ServerAlias *.queenscrosschurch.org.uk
</VirtualHost>


Yet both websites are displaying the robertsontheweb site. So the DNS
servers seem to be pointing to the correct place. The result is
the same with ServerAlias in or out. I have read as much as I can find on the web, including the faq recommened elsewhere in this forum, but to no avail!

Any help would be very much appreciated!

Dave Roberts
 
Change your <VirtualHost *:80> and NameVirtualHost *:80 to include your ip address in which the webserver is listening on for all your sites.

ie:

NameVirtualHost 10.10.10.10:80

<VirtualHost 10.10.10.10:80>
ServerName ServerAdmin drder@robertsontheweb.co.uk
DocumentRoot /#ServerAlias robertsontheweb.co.uk *.robertsontheweb.co.uk
</VirtualHost>

<VirtualHost 10.10.10.10:80>
ServerName DocumentRoot /#ServerAlias *.queenscrosschurch.org.uk
</VirtualHost>


This should correct your issue.
NOTE: The 10.10.10.10 ip address is just an example. Use the ip address that of your webserver.


Michael


WarpZero Technologies
 
Hi Michael,
unfortunately, that didn't fix it. Could the problem be with how 1 & 1 has their DNS servers setup? I have it set to forward to my IP address, maybe it the forward does not include the queenscross bit, so Apache just goes to the default. It there something I can add to forwarding address to include queenscross?

Thanks!

Dave
 
Hi Dave,
I did a dns check on your above names and found that you have 2 different ip's for each domain. In this case don't use NameVirtualHost. Comment that out and change the VirtualHost for each site to have the specific ip and you will be good.

ie:
#NameVirtualHost x.x.x.x:80

<VirtualHost 212.227.127.93:80>
ServerName ServerAdmin drder@robertsontheweb.co.uk
DocumentRoot /#ServerAlias robertsontheweb.co.uk *.robertsontheweb.co.uk
</VirtualHost>

<VirtualHost 212.227.127.206:80>
ServerName DocumentRoot /#ServerAlias *.queenscrosschurch.org.uk
</VirtualHost>

If you don't want different IP's for each site then you will have to contact your ISP.


Michael


WarpZero Technologies
 
Hi Michael,

Thanks again for your help, but still no joy. Arg! Any other ideas?

Dave
 
Even though the websites have different ip address, bith of them are set to forward to a single ip address (where my server is), so do I need name-based or ip based virtual hosts. The server only has one ip address.
Could this be an issue with my router(Netgear DG834)? Am I missing something blindingly obvious??

Dave
 
Are you natting your traffic? If so try the following

1) put a local entry within the hosts file on the server with both names pointing to the ip that the webserver is listening on.

ie:
10.10.10.10
2) Make sure you are able to ping both names and that they resolve to the IP address within the hosts file

3) Configure both <VirtualHost x.x.x.x:80> with the same IP

4) restart the webserver and try.

I have seen that problem where the firewall nat's the traffic and the webserver is resolving the name to an IP that of the DNS not matching the address of the server. Hence the default webserver responds and none of the other sites work.


Michael


WarpZero Technologies
 
That makes sounds like a very good idea. I will try it out tomorrow and let you know how it works.
Thanks again for all of your help - it is very much appreciated!

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top