?
Solved

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

Posted on 2004-08-18
10
Medium Priority
?
436 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
Suggested Courses

764 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