Solved

Name Virtual Host and/or Virtual Host not working...

Posted on 2004-08-18
10
431 Views
Last Modified: 2013-11-15
I have been going around in a circle for a few days.  Basically, the problem here is that the 2nd website kept defaulting to the 1st website.  I'm using the IP Address based virtual host because I'm behind the firewall and because it's faster when there's problem with the Internet (like DNS, down Internet connection, etc...).  The 2nd website is accessible only behind the firewall, not accessible to the public.  The 1st website is accessible to the public and behind the firewall.  I'm going to post the script here...  I'm using hte Unix server and the machine name is chevy.  I'm also wondering if creating a fake ip address is ever possible...

#/etc/hosts (Script below)
--snip--
127.0.0.1               loopback localhost      # loopback (lo0) name/address

#IP Address for this Machine...
xx.xx.x.90    chevy chevy.xxxx.com

#IP Address for Websites
xx.xx.xx.90    firstwebsite.xxxx.com
xx.xx.xx.91    secondwebsite.xxxx.com
--snip--

#httpd.conf (Script below - trimmed)
--snip--
#Listen xx.xx.xx.90:80
#Listen xx.xx.xx.90:443
#Listen xx.xx.xx.91:80
#Listen xx.xx.xx.91:443

NameVirtualHost xx.xx.xx.90:80
NameVirtualHost xx.xx.xx.90:443
NameVirtualHost xx.xx.xx.91:80
NameVirtualHost xx.xx.xx.91:443

<VirtualHost xx.xx.xx.90:80>
    ServerName firstwebsite.xxxx.com
    DocumentRoot "/home/website/firstwebsite/www"
    DirectoryIndex index.php
</VirtualHost>

<VirtualHost xx.xx.xx.90:443>
    ServerName firstwebsite.xxxx.com
   DocumentRoot "/home/website/firstwebsite/secure"
   DirectoryIndex login_page.php
</VirtualHost>

<VirtualHost xx.xx.xx.91:80>
    ServerName secondwebsite.xxxx.com
    DocumentRoot "/home/website/secondwebsite/www"
    DirectoryIndex index.php
</VirtualHost>

<VirtualHost xx.xx.xx.91:443>
    ServerName secondwebsite.xxxx.com
   DocumentRoot "/home/website/secondwebsite/secure"
   DirectoryIndex login_page.php
</VirtualHost>
--snip--

#Response as result of command line "httpd -S"
--snip--
VirtualHost configuration:
xx.xx.xx.90:80        is a NameVirtualHost
                            default server firstwebsite.xxxx.com (/xx/httpd.conf:1264)
                            port 80 namevhost firstwebsite.xxxx.com (/xx/httpd.conf:1264)
xx.xx.xx.90:443      is a NameVirtualHost
                            default server firstwebsite.xxxx.com (/xx/httpd.conf:1299)
                            port 443 namevhost firstwebsite.xxxx.com (/xx/httpd.conf:1299)
xx.xx.xx.91:80        is a NameVirtualHost
                            default server secondwebsite.xxxx.com (/xx/httpd.conf:1351)
                            port 80 namevhost secondwebsite.xxxx.com (/xx/httpd.conf:1351)
xx.xx.xx.91:443      is a NameVirtualHost
                            default server secondwebsite.xxxx.com (/xx/httpd.conf:1386)
                            port 443 namevhost secondwebsite.xxxx.com (/xx/httpd.conf:1386)
--snip--

Thanks,
 Scott Fletcher
0
Comment
Question by:fletchsod
10 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11830913
how do you access the server? could you pleast post the exact URL
0
 
LVL 15

Expert Comment

by:samri
ID: 11831671
how does the xx.xx.xx.91 resolve to, is it secondwebsite.xxx.com or firstwebsite.xxx.com

try to do nslookup 91.xx.xx.xx.in-addr.arpa   (replace the xx's with the real ip addre in reverse, so if your real ip is 1.2.3.91, then nslookup 91.3.2.1.in-addr.arpa).

Alternately, you could try to add modify:
<VirtualHost xx.xx.xx.91:80>
    ServerName secondwebsite.xxxx.com
    ServerAlias xx.xx.xxx.91                             <<-- add this line.
    DocumentRoot "/home/website/secondwebsite/www"
    DirectoryIndex index.php
</VirtualHost

--
give it a shot.
0
 

Author Comment

by:fletchsod
ID: 11832984
>> how do you access the server? could you pleast post the exact URL?
Well, the website is not accessible on the Internet just yet.  But all is not lost, there is one other website that use this exact configuration which doesn't work either.  It is www.e-cbi.com, the problem is you only see the public ip address which is 64.31.133.14.  When it reach the firewall, a different ip address is used behind the firewall, known as private ip address.  That's where the xx.xx.xx.90 come into play.  The second website is test.e-cbi.com and it does not exist on the Internet, just us employees on local network who can access it.

>> how does the xx.xx.xx.91 resolve to, is it secondwebsite.xxx.com or firstwebsite.xxx.com
The xx.xx.xx.91 resolve to the secondwebsite.xxx.com.

>>try to do nslookup 91.xx.xx.xx.in-addr.arpa
Tried that and got a error message, see below
--snip--
*** Can't find server name for address 64.31.129.6:No response from server
*** Can't find server name for address 64.66.88.6:No response from server
*** Default servers are not available
--snip--
The server is configured to depend on itself and on the host file.  The DNS is disabled here because of the firewall.

>>    ServerAlias xx.xx.xxx.91                             <<-- add this line.
 Tried that and it still doesn't work.  Apache kept picking the firstwebsite.xxx.com...

Scott Fletcher
0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
LVL 15

Expert Comment

by:samri
ID: 11833308
i would assume that you have gone thru Apache docs on Vhost ont he following link?

http://httpd.apache.org/docs-2.0/vhosts/
http://httpd.apache.org/docs-2.0/vhosts/details.html
0
 

Author Comment

by:fletchsod
ID: 11834663
I use Apache 1.3.27, not the 2.0 version.  So, I did see and look through the documentation at
http://httpd.apache.org/docs/vhosts/ip-based.html and  http://httpd.apache.org/docs/vhosts/name-based.html and stuffs like that.  So, anyway, I saw some new information from the links you provided for the docs-2.0 directory that wasn't in the docs directory..

1) ServerAlias and ServerPath checks are never performed for an IP-based vhost
2) # If two IP-based vhosts have an address in common, the vhost appearing first in the config file is always matched. Such a thing might happen inadvertently. The server will give a warning in the error logfile when it detects this.
3) You should never specify DNS names in VirtualHost directives because it will force your server to rely on DNS to boot
4) ServerName should always be set for each vhost. Otherwise A DNS lookup is required for each vhost

While what I read from the docs directory

1)  It is recommended that you use an IP address instead of a hostname
2) If your server doesn't have to perform DNS for any other reason then you might be able to get away with running Apache with the HOSTRESORDER environment variable set to "local". This all depends on what OS and resolver libraries you are using.
3) Tips to Avoid these problems

    * use IP addresses in <VirtualHost>
    * use IP addresses in Listen
    * use IP addresses in BindAddress
    * ensure all virtual hosts have an explicit ServerName
    * create a <VirtualHost _default_:*> server that has no pages to serve

0
 

Author Comment

by:fletchsod
ID: 11846030
Aw, forget it.  I can't wait any longer.  I just made the secondwebsite.xxxx.com to use the same IP Address as the firstwebsite.xxxx.com, the same IP Address as the webserver's IP Address and that took care of the problem.  I don't know why it won't work with other IP Addresses...  So, closing this report....   (Will contact the community something...)
0
 
LVL 15

Expert Comment

by:samri
ID: 11853028
no objection.
0
 

Author Comment

by:fletchsod
ID: 11855848
>>fletchsod: If you have not responded to the Experts concerning your question or given an updated status, your
>>points will not be refunded.
Me??  I already provided the answer from just one posting before your comments..  The answer was that I start using the the same IP Address for 2 websites because there's no way to get the 2nd IP Address to work.  So far, so good.

Scott Fletcher
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11875766
Closed, 250 points refunded.
Netminder
Site Admin
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question