PDA

View Full Version : virtual host won't direct to proper site



ztechguy
13th February 2007, 11:17 PM
I've scoured virtual hosts postings, and have come up short. I'm using a config that I have working on another redhat box and I must be missing something. At the time I just have 2 sites hosted, and I want to use name based virtualhost. Here is an example of my virtual host part of my httpd.conf config. I subsituted the email and servernames with bogus names. mydomain1.dyndns.org and mydomain2@gotdns.org are the seperate sites that I have listed with dyndns.

Am I missing a switch somewhere else to force the virtualhost. What happens is I can get to the first virtual host but I cannot get to the second one. Both names bring me back to the same site.

Any help?

Thanks,

ztechguy

#
# Use name-based virtual hosting.
#
NameVirtualHost 192.168.15.150:80

# Where do we put the lock and pif files?
LockFile "/var/lock/httpd.lock"
CoreDumpDirectory "/etc/httpd"

# Defaults for virtual hosts

# Logs

#
# Virtual hosts
#
# Virtual host Virtual Host 0
<VirtualHost 192.168.15.150:80>
DocumentRoot /var/www/html/joomla
ServerAdmin myname@mydomain.org
ServerName mydomain1.dyndns.org
DirectoryIndex index.html index.php index.htm index.shtml
<Directory "/var/www/html/joomla">
Options all -Indexes
AllowOverride none
Allow from all
Deny from all
Order Deny,Allow
</Directory>
</VirtualHost>

#Virtual host Virtual Host 1
<VirtualHost 192.168.15.150:80>
DocumentRoot /var/www/html/homeweb
ServerAdmin myname@myemail.org
ServerName mydomain2.gotdns.org
DirectoryIndex index.html index.php index.htm index.shtml
<Directory "/var/www/html/homeweb">
Options all -Indexes
AllowOverride none
Allow from all
Deny from all
Order Deny,Allow
</Directory>
</VirtualHost>

JordanN
14th February 2007, 01:30 AM
The first VirtualHost listing is going to be the default site. This is the one that Apache uses when it doesn't find a match. Use the first listing as a "Safe" site, what the users should get when they enter your server's IP, for example. For example, you could show a listing of all of the sites hosted on your server, with relative paths.

The server name should be the perfect URL. For example,
ServerName www.example.com:80. For every variation on this URL, use the ServerAlias line:

ServerAlias example.com

Try adding the port specifier to the ServerName line.

ztechguy
14th February 2007, 02:56 PM
Thanks for the tip, I gathered that the first was the safe site, or the default if it could not resolve the following sites. I did some more investigating and found that it is actually a problem with my ssl.conf config. I was trying to get two seperate sites to run with two seperate ssl configs. The only port I have open is port 443 to the outside. When I came home and tried the local address on http port 80 I found that it was working fine.
So I guess the question is now is there any documentation for creating two seperate ssl certificates. Here is how I created the certificate.
1) cd /etc/pki/tls/private
>
> 2) openssl genrsa -out server.key 1024
>
> 3) openssl req -new -key server.key -out server.csr
>
> 4) openssl x509 -req -in server.csr -signkey server.key -out ../certs/server.crt
>
> 5) restart httpd server
>

How can I create a second cert that won't re-write over the first? Then I should just be able to modify the cert paths in the ssl.conf file.



Thanks,