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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTPD VirtualHost difficulties

Status
Not open for further replies.

Borvik

Programmer
Jan 2, 2002
1,392
US
I'm having some difficulty getting Virtual Hosting to work correctly. Here is the portion of my httpd.conf file that pertains to Virtual Hosting.
Code:
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.
#
#<VirtualHost *>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /[URL unfurl="true"]www/docs/dummy-host.example.com[/URL]
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
<VirtualHost *:80>
	ServerAdmin <email>
	DocumentRoot /var/[URL unfurl="true"]www/html/default[/URL]
	ServerName <other>
	ErrorLog logs/default-error_log
	CustomLog logs/default-access_log common
</VirtualHost>

<VirtualHost <external_ip1>:80>
	ServerAdmin <email>
	DocumentRoot /var/[URL unfurl="true"]www/html/dir1[/URL]
	ServerName <main>
	ErrorLog logs/dir1-error_log
	CustomLog logs/dir1-access_log common
</VirtualHost>
<VirtualHost <external_ip2>:80>
	ServerAdmin <email>
	DocumentRoot /var/[URL unfurl="true"]www/html/dir2[/URL]
	ServerName <secondary>
	ErrorLog logs/dir2-error_log
	CustomLog logs/dir2-access_log common
</VirtualHost>
<VirtualHost <local_ip>:80>
	ServerAdmin <email>
	DocumentRoot /var/[URL unfurl="true"]www/html/local[/URL]
	ServerName <internal>
	ErrorLog logs/local-error_log
	CustomLog logs/local-access_log common
</VirtualHost>

Here's what happens. I go to a machine on our network and use the local_ip and it pulls up the correct page. I use the localhost and it pulls up the default page. I use an external machine and use external_ip2 and it pulls up the correct page, but when I use external_ip1 I get the Apache test page instead of the index file I have in the /var/ directory. Any ideas?
 
My guess is that since you have apparently accounted for all of your machine's IP addresses in other VHosts, it is probable that the *:80 will never get hit....

Hosting Solutions for Home or Business.
 
*:80 does get hit - through the localhost
<local_ip>:80 works
<external_ip2>:80 works

its <external_ip1>:80 that has the problem and is bringing up the Apache test page.
 
now both the localhost and <external_ip1> get the Apache Test page.
 
Well, there is the default DocumentRoot that is defined for non-Virtual Host servers, but I've commented that out and the <directory> directive that complements it and it still happens.
 
You are telling apache to use name based addressing by using the "NameVirtualHost" directive yet you are using ip addressing (sort of) in your vhost containers. Unless you really need to use ip addressing I would go with name based addressing and let apache find the correct virtual host by the "ServerName" directive of each vhost.
 
Well, we currently host websites on an IIS server - and it is currently setup with IP address (which we have plenty of). I'm not sure if we have any SSL sites, so better to use IPs to make sure it works.
 
Well I figured it out. I feel kinda stupid now, but it was a simple permissions problem. Every directory that worked had a chmod of 755 while the one that didn't had one of 700 - so of course I would be able to view anything. Thanks though to all who tried.
 
OK, now the $64,000 Security question class...
What's wrong with 755 perms the hosting folders on a shared hosting environment? Hint, local users.

Hosting Solutions for Home or Business.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top