Q:

Apache2 - always serves default VHOST

I know that there are a lot of questions / answers to it, but none did solve my problem.
My setup:
- I got 2 subdomains (sub1.test.de and sub2.test.de) which are configured to do a proxy redirect to the same IP (the IP of my virtual machine, which is somewhere else)
- I got two configuration files for my vhosts
- virtual machine is running Ubuntu 14.04
I tried setting NameVirtualHost *:80, putting all vhosts in one config file instead of separate ones, setting NameVirtualHost *:80 inside ports.conf and specifying the IP instead of a wildcard, but with no luck. Opening sub2.test.de still redirects me to sub1.test.de.
this is my sub1.test.de.conf:
<VirtualHost *:80>
    ServerName sub1.test.de

    ServerAdmin webmaster@test.de
    DocumentRoot /var/www/sub1.test.de/html

    # 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

    ErrorLog /var/www/sub1.test.de/log/error.log
    CustomLog /var/www/sub1.test.de/log/access.log combined

    # Wildfly api Prox Bypass
    ProxyPass /api http://someip:8080/api
    ProxyPassReverse /api http://someip:8080/api

    # Websocket Proxy Bypass
    RewriteEngine on
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule .* ws://sub1.test.de:9000%{REQUEST_URI} [P]

    ProxyPass /socket http://someip:9000/socket
    ProxyPassReverse /socket http://someip:9000/socket

    <Directory /var/www/sub1.test.de/html>

        # Enable rewriting
        RewriteEngine On

        # If its not HTTPS
        # RewriteCond %{HTTPS} off

        # Comment out the RewriteCond above, and uncomment the RewriteCond below if you're using a load balancer (e.g. CloudFlare) for SSL
        # RewriteCond %{HTTP:X-Forwarded-Proto} !https

        # Redirect to the same URL with https://, ignoring all further rules if this one is in effect
        #RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R,L]

        # If we get to here, it means we are on https://

        # If the file with the specified name in the browser doesn't exist
        RewriteCond %{REQUEST_FILENAME} !-f

        # and the directory with the specified name in the browser doesn't exist
        RewriteCond %{REQUEST_FILENAME} !-d

        # and we are not opening the root already (otherwise we get a redirect loop)
        RewriteCond %{REQUEST_FILENAME} !\/$

        # Rewrite all requests to the root
        RewriteRule ^(.*) /

    </Directory>

and this is my sub1.test.de.conf:
<VirtualHost *:80>
    ServerName sub2.test.de

    ServerAdmin webmaster@test.de
    DocumentRoot /var/www/sub2.test.de/html

    # 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

    ErrorLog /var/www/sub2.test.de/log/error.log
    CustomLog /var/www/sub2.test.de/log/access.log combined

    # Wildfly api Prox Bypass
    ProxyPass /api http://someip:8080/api
    ProxyPassReverse /api http://someip:8080/api

    <Directory /var/www/sub2.test.de/html>

        # Enable rewriting
        RewriteEngine On

        # If its not HTTPS
        # RewriteCond %{HTTPS} off

        # Comment out the RewriteCond above, and uncomment the RewriteCond below if you're using a load balancer (e.g. CloudFlare) for SSL
        # RewriteCond %{HTTP:X-Forwarded-Proto} !https

        # Redirect to the same URL with https://, ignoring all further rules if this one is in effect
        #RewriteRule ^(.*) https://%{HTTP_HOST}/$1 [R,L]

        # If we get to here, it means we are on https://

        # If the file with the specified name in the browser doesn't exist
        RewriteCond %{REQUEST_FILENAME} !-f

        # and the directory with the specified name in the browser doesn't exist
        RewriteCond %{REQUEST_FILENAME} !-d

        # and we are not opening the root already (otherwise we get a redirect loop)
        RewriteCond %{REQUEST_FILENAME} !\/$

        # Rewrite all requests to the root
        RewriteRule ^(.*) /

    </Directory>

apachectl -t -D DUMP_VHOSTS gives me the following output:
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 2a01:4f8:c0c:365::2. Set the 'ServerName' directive globally to suppress this message

VirtualHost configuration:

*:80                   is a NameVirtualHost
         default server sub1.test.de (/etc/apache2/sites-enabled/sub1.test.conf:3)
         port 80 namevhost sub1.test.de (/etc/apache2/sites-enabled/sub1.test.de.conf:3)
         port 80 namevhost sub2.test.de (/etc/apache2/sites-enabled/sub2.test.de.conf:1)

Still, opening sub2.test.de always to me sub1.test.de. What am I doing wrong?

A:

I solved it. The problem was, that I had a regular redirect entry from where my domains are listed rather than an A-NAME record. After I changed the redirect to an A-NAME Record and waiting few hours for DNS refresh, everything worked fine.

