I have just moved from Amazon EC2 to another VPS, running Ubuntu 12.04 on both of them. But now I get some very strange redirections.
No matter which domain name I access using http (port 80) I end up on the same domain. I have no redirections to this domain.
http://domain1.com works fine, but http://domain2.com redirects to http://domain1.com Even if I just enter the IP-adress, I get domain1.com. It seems Apache2 can't resolve what name the request is coming from.
If I access over SSL at https://domain2.com, it loads just fine with no redirection.
I think I deleted the "default.conf" file in the "sites-enabled"-folder just after installing apache2. Can this have any influence?
Here is the apache2ctl -S
output:
AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/ports.conf:5
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 is a NameVirtualHost
default server domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:1)
port 80 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:1)
port 80 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:1)
alias www.domain2.com
*:443 is a NameVirtualHost
default server domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:10)
port 443 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:10)
port 443 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:9)
alias www.domain2.com
port 443 namevhost domain3.com (/etc/apache2/sites-enabled/domain3.com.conf:2)
alias www.domain3.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
And this is my domain1.com.conf (completely similar to domain2.com.conf except for the domain names):
<VirtualHost *:80>
ServerName domain1.com
ServerAdmin my@email.com
DocumentRoot /var/www/domain1.com
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName domain1.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/domain1.com
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/domain1.com/domain1.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/domain1.com/domain1.com.key
SSLCertificateChainFile /etc/apache2/ssl/domain1.com/sub.class1.server.ca.pem
# Security settings for SSL
SSLProtocol ALL -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet