LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-10-2007, 09:23 PM   #1
Splenden
Member
 
Registered: Jan 2007
Posts: 32

Rep: Reputation: 15
Apache - VirtualHost setting not working?


Hi,

I just set up my Apache configuration file, and I added a VirtualHost (IP-based) for one domain that I am hosting on my server. There are no errors, however, the domain seems to be reading the htdocs folder instead of the DocumentRoot set for the VirtualHost. Here is the VirtualHost in question, of course with all domain/IP details removed.

Code:
<VirtualHost the.ip.address.here>
        ServerAdmin removed@email.address
        DocumentRoot /home/domain.com/public_html
        ServerName domain.com
        ServerAlias www.domain.com
        ErrorLog /home/domain.com/logs/error_log
        CustomLog /home/domain.com/logs/access_log common
        ScriptAlias /cgi-bin/ "/home/domain.com/cgi-bin"
</VirtualHost>
Here is my full httpd.conf file (not very long, so I am posting it here).

Code:
ServerRoot "/usr/local/apache"
Listen 80

LoadModule php5_module		modules/libphp5.so

<IfModule !mpm_netware_module>
	User daemon
	Group daemon
</IfModule>

ServerAdmin domain@removed.com
DocumentRoot "/usr/local/apache/htdocs"

<Directory />
	Options FollowSymLinks
	AllowOverride None
	Order deny,allow
	Deny from all
</Directory>

<Directory "/usr/local/apache/htdocs">
	Options Indexes FollowSymLinks
	AllowOverride  None
	Order allow,deny
	Allow from all
</Directory>

<IfModule dir_module>
	DirectoryIndex index.html
</IfModule>

<FilesMatch "^\.ht">
	Order allow,deny
	Deny from all
	Satisfy All
</FilesMatch>

ErrorLog logs/error_log
LogLevel warn

<IfModule log_config_module>
	LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i"" combined
	LogFormat "%h %l %u %t \"%r\" %>s %b" common

	<IfModule logio_module>
		LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
	</IfModule>

	CustomLog logs/access_log common
</IfModule>

<IfModule alias_module>
	ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
</IfModule>

<Directory "/usr/local/apache/cgi-bin">
	AllowOverride None
	Options None
	Order allow,deny
	Allow from all
</Directory>

DefaultType text/plain

<IfModule mime_module>
	TypesConfig conf/mime.types
	AddType application/x-compress .Z
	AddType application/x-gzip .gz .tgz
</IfModule>

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

<VirtualHost the.ip.address.here>
        ServerAdmin removed@email.address
        DocumentRoot /home/domain.com/public_html
        ServerName domain.com
        ServerAlias www.domain.com
        ErrorLog /home/domain.com/logs/error_log
        CustomLog /home/domain.com/logs/access_log common
        ScriptAlias /cgi-bin/ "/home/domain.com/cgi-bin"
</VirtualHost>
Please let me know if you see any errors that would prevent it from reading VirtualHost directives.

Thanks!

Splenden
 
Old 01-11-2007, 02:15 AM   #2
leandean
Member
 
Registered: Oct 2005
Location: Burley, WA
Distribution: Sabayon
Posts: 276

Rep: Reputation: Disabled
Looks to me that it sees the default path: DocumentRoot "/usr/local/apache/htdocs" and doesn't have anything to tell it to look for a virtual host:

NameVirtualHost *:80

See:

http://httpd.apache.org/docs/2.0/vhosts/examples.html
 
Old 01-11-2007, 10:47 AM   #3
Splenden
Member
 
Registered: Jan 2007
Posts: 32

Original Poster
Rep: Reputation: 15
Does that apply for an IP-based virtual host? I am using unique IPs for all of my sites right now.

Thanks!

Splenden
 
Old 01-12-2007, 02:25 AM   #4
poweredbydodge
Member
 
Registered: Oct 2006
Location: Buffalo, NY
Distribution: Servers: Scientific Linux 5.x // Desktops: Fedora Core (latest)
Posts: 110

Rep: Reputation: 15
Not to be back-asswards, but a single server shouldn't have more than one WAN IP address. I can understand multiple NIC's for varied LAN IP's, but one machine should only be accepting / broadcasting to one WAN IP, and therefore, I do not think Apache is setup to work on multiple IP's.

Obviously, the *:80 or *:443 or *:whatever-port will allow it to glom over and serve HTTP(S) to all IPs that come up for the machine. However, I am not so sure this was intended to be used for differentiating directories to be served by IP address.

None the less, I think your 'calling' of the VirtualHost directive is missing the port.

Quote:
<VirtualHost ip.address.hereort>
-----replace smiley face with : p ---
blah
blah
blah
</VirtualHost>
... might work. Your inital post showed that you placed the IP address in the call, but not the port. It could be something that simple.

Last edited by poweredbydodge; 01-12-2007 at 02:27 AM.
 
Old 01-13-2007, 12:18 AM   #5
Splenden
Member
 
Registered: Jan 2007
Posts: 32

Original Poster
Rep: Reputation: 15
Dedicated servers and VPS'es can sometimes have more than one IP address - in fact, they usually do. It is not uncommon to see one machine with several IP addresses on it and one NIC.

I'll try the port thing and report back in the morning.

Thank you.

Splenden
 
Old 01-14-2007, 01:50 AM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by poweredbydodge
Not to be back-asswards, but a single server shouldn't have more than one WAN IP address. I can understand multiple NIC's for varied LAN IP's, but one machine should only be accepting / broadcasting to one WAN IP,
Just curious: Why?

I use IP-based virtual hosting (one nic, 4 addresses). I 'have to' as the 4 sites that I host (on an intranet) are all https sites; the only alternative is four dedicated servers.
I might be wrong, but I can't imagine that a hosting provider buys a new server for every client that wants https.
 
Old 01-14-2007, 02:20 AM   #7
poweredbydodge
Member
 
Registered: Oct 2006
Location: Buffalo, NY
Distribution: Servers: Scientific Linux 5.x // Desktops: Fedora Core (latest)
Posts: 110

Rep: Reputation: 15
well... i hadn't thought about that.

although, i had thought that 'big servers' (the type that do hosting for various websites and such) just used domain name virtual hosting.

ie -- joeblow.com and myothersite.com would both redirect to the same IP, with virtual hosting taking care of sending requests for each to their respective directories.

as far as https goes, taking into account what i just said, certificates don't really care what IP they're coming from, they reference the domain. as long as the issuer and holder are from the domain calling https, then it shouldn't be an issue... i've run 3 domain names from my single IP address, all with virtual hosting, and all were able to run https.
 
Old 01-14-2007, 12:43 PM   #8
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
I wonder how you got that working; I could not get it working as I get the message in my browser that the certificate is not valid for the domain (or something like that; can't remember exact text anymore).

from http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html
Quote:
Why is it not possible to use Name-Based Virtual Hosting to identify different SSL virtual hosts?

Name-Based Virtual Hosting is a very popular method of identifying different virtual hosts. It allows you to use the same IP address and the same port number for many different sites. When people move on to SSL, it seems natural to assume that the same method can be used to have lots of different SSL virtual hosts on the same server.

It comes as rather a shock to learn that it is impossible.

The reason is that the SSL protocol is a separate layer which encapsulates the HTTP protocol. So the SSL session is a separate transaction, that takes place before the HTTP session has begun. The server receives an SSL request on IP address X and port Y (usually 443). Since the SSL request does not contain any Host: field, the server has no way to decide which SSL virtual host to use. Usually, it will just use the first one it finds, which matches the port and IP address specified.
 
Old 01-14-2007, 12:56 PM   #9
Splenden
Member
 
Registered: Jan 2007
Posts: 32

Original Poster
Rep: Reputation: 15
It was something in the config file. I decided to redo my config file and it worked fine. User error.

Thank you!

Splenden
 
Old 01-14-2007, 01:15 PM   #10
leandean
Member
 
Registered: Oct 2005
Location: Burley, WA
Distribution: Sabayon
Posts: 276

Rep: Reputation: Disabled
You can only run one ssl server per port or address. To run more you must specify a separate port/address for each. ie: :443, 444, etc.

http://lists.freebsd.org/pipermail/f...il/000119.html

You can only resolve on SSL certificate to any given IP/port configuration.

Your apache conf file can be listening to 30 different IP address/port
configurations, and have 30 seperate SSL certificates for each.
<VirtualHost 123.456.789.1:443>
<VirtualHost 123.456.789.1:444>
<VirtualHost 123.456.789.1:445>
<VirtualHost 123.456.789.1:446>
or
<VirtualHost 123.456.789.1:443>
<VirtualHost 123.456.789.2:443>
<VirtualHost 123.456.789.3:443>
<VirtualHost 123.456.789.4:443>
are all acceptable with the appropriate certificate entries in each container.

You cannot however, have more than 1 SSL certificate for a single IP/Port
configuration.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache -VirtualHost davidhk Debian 7 08-19-2005 01:33 PM
Setting Apache Virtualhost Default Document? Seventh Linux - Software 1 03-21-2005 11:47 AM
Help with Apache <VirtualHost> please. smakkythecamel Linux - Networking 2 06-12-2003 08:15 PM
setting virtualhost without IP acid_kewpie Linux - Networking 3 12-10-2002 08:45 AM
apache virtualhost jonfa Linux - Networking 5 08-12-2002 07:07 PM


All times are GMT -5. The time now is 10:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration