Apache Web Server Virtual Host Problem

I was setting up virtual hosting for multiple hosts on my Apache web server. I followed the instructions for virtual name based hosting from the apache site at:
Name-based Virtual Host Support. I set up two virtual hosts: 1. For my default web site which my Fedora Linux server is the host. The other is an additional site that I wanted hosted on the same server. Additionally, I added a host entry to the /etc/hosts file for each of the domains I wanted to handle. Which ever host I would create first in the httpd.conf file would direct to entries of either of my domains. In other words domain1.com and domain2.com would land at which ever the first virtual host entry was in my httpd.conf file. After hours of changing configuration and trying to get Apache to redirect the different requests, I figured a solution.
Solution
I created virtual host entries exactly as in the Apache example:
NameVirtualHost *
ServerName www.domain1.com
DocumentRoot /www/domain
I think the problem was that ip address coming in through my router was different that my /etc/hosts entry. To reiterate, my server is behind a router and configured to forward requests to a local ip. I changed my virtual host entries in the httpd.conf file to point to the local ip like this:
NameVirtualHost 192.168.1.2:80
ServerName www.domain1.com
DocumentRoot /www/domain
This worked for me. If you have questions please feel free to email me.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home