Solved

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

Posted on 2004-08-18
10
425 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now