Please excuse if this is a beginner-level question, but I need some advice urgently.
I want to run two websites, say foo.org
and bar.info
, on the same server. Both should be reachable by http and https. My directory /etc/apache2/sites-enabled
contains the files foo
and bar
.
The two files look like this (omitting some entries for logging):
foo
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.foo.org
DocumentRoot /var/www/dir
ServerAlias foo.org foo.de www.foo.de
RewriteEngine On
RewriteOptions inherit
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName www.foo.org
DocumentRoot /var/www/dir
ServerAlias www.foo.de
RewriteEngine On
RewriteOptions inherit
# # SSL Specific options
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>
bar
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName blog.bar.info
DocumentRoot /var/www/bar/blog
ServerAlias www.blog.bar.info
RewriteEngine On
RewriteOptions inherit
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName analytics.bar.info
DocumentRoot /var/www/bar/analytics
# ServerAlias
RewriteEngine On
RewriteOptions inherit
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName blog.bar.info
DocumentRoot /var/www/bar/blog
RewriteEngine On
RewriteOptions inherit
# # SSL Specific options
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>
The main problem is that when accessing https://foo.org, it is now redirected to https://blog.bar.info.
With http, it seems to work fine.
What is my error? Also: How can I ensure that one site is never ever redirected to the other?
EDIT: The ports.conf
file contains:
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>