I'm configuring an apache server to support a few virtual hosts with different subdomains. Situation:
Right now, there are 4 subdomains pointing to same IP:
srv.example.com
svn.example.com
mail.example.com
mysql.example.com
List will be extended later with other names. First one, should load default vhost with something like Welcome page. Second one used in vhost serving svn repos, third one a webmail client and last one phpmyadmin.
Next, i have 4 sites enabled:
000-default.conf -> ../sites-available/000-default.conf
010-svn.conf -> ../sites-available/010-svn.conf
020-roundcube.conf -> ../sites-available/020-roundcube.conf
090-phpmyadmin.conf -> ../sites-available/090-phpmyadmin.conf
First one is a default apache2 config:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Second, svn repos host configuration:
<VirtualHost 192.168.22.11:38443>
ServerName svn.example.com
<Location />
... SVN stuff ...
</Location>
... SSL stuff ...
</VirtualHost>
Webmail vhost:
<VirtualHost *:443>
ServerName mail.example.com
DocumentRoot /home/webapps/roundcubemail-1.1.2
... SSL stuff ...
<Directory "/home/webapps/roundcubemail-1.1.2">
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName mail.example.com
Redirect / https://mail.example.com/
</VirtualHost>
And phpmyadmin:
<VirtualHost 192.168.22.11:80>
ServerName mysql.example.com
DocumentRoot /usr/share/phpmyadmin
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
LogLevel notice
CustomLog /var/log/apache2/access.log combined
ErrorLog /var/log/apache2/error.log
ServerSignature On
</VirtualHost>
So, again, its supposed to:
http://srv.example.com => land on 'default' vhost (000-def...)
http://svn.example.com => land on 'default' as SVN is served on 38443 port
http://svn.example.com:38443 => land on svn vhost
http://mail.example.com => redirect to https://mail.example.com
https://mail.example.com => land on webmail vhost
http://mysql.example.com => land on phpmyadmin vhost
But, its no working like this:
http://srv.example.com => loads phpmyadmin vhost
http://svn.example.com => loads phpmyadmin vhost too
http://svn.example.com:38443 => lands on svn vhost
http://mail.example.com => loads phpmyadmin vhost
https://mail.example.com => land on webmail vhost
http://mysql.example.com => land on phpmyadmin vhost
So, generally, apache2 is taking last vhost (mysql) as default one. And for some reason mail redirect is not working.
I have no idea whats wrong, as i googled some, it should work, when subdomain doesn't fit to any of defined vhosts, it should load first one (000-default as from order of symlinks) - so why it loads last one?
Edit 11.09.2015
Problem seems to be in phpmyadmin configuration, when i disable its vhost, everything works as expected, and when i enable it again its bad again.
Dont know why this happens...