Score:0

Apache2 Default HTTPS 443 Vhost

us flag

I'm currently trying to make a default vhost for HTTPS to block traffic from unauthorized domains. However, when I define a default 443 vhost, ALL other HTTPS vhosts inherit this as well and prevents normal access. I've been scratching my head for hours about this...

Apache Info:

OS: Ubuntu Server 20.04

Server version: Apache/2.4.41 (Ubuntu)

Server built: 2022-03-16T16:52:53

Here's my default vhosts file:

<VirtualHost _default_:80>

        ServerName default

        Alias /error/ /var/www/redirects/

        ErrorDocument 400 /error/400.html
        ErrorDocument 401 /error/401.html
        ErrorDocument 402 /error/402.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 405 /error/405.html
        ErrorDocument 408 /error/408.html
        ErrorDocument 503 /error/maintenance.html

        <Location />
                Require all denied
        </Location>

</VirtualHost>

<VirtualHost _default_:443>

        ServerName default

        Alias /error/ /var/www/redirects/

        ErrorDocument 400 /error/400.html
        ErrorDocument 401 /error/401.html
        ErrorDocument 402 /error/402.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 405 /error/405.html
        ErrorDocument 408 /error/408.html
        ErrorDocument 503 /error/maintenance.html

        <Location />
                Require all denied
        </Location>

</VirtualHost>

And the rest are within separate config files and enabled using sudo a2ensite mydomain.com.conf

Here is one of those configs:

<IfModule mod_ssl.c>
<VirtualHost *:443>
     ServerName mydomain.com
     ServerAlias mydomain.com

        Alias /error/ /var/www/redirects/

        ErrorDocument 400 /error/400.html
        ErrorDocument 401 /error/401.html
        ErrorDocument 402 /error/402.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 405 /error/405.html
        ErrorDocument 408 /error/408.html
        ErrorDocument 503 /error/maintenance.html

     DocumentRoot /var/www/html/mydomain.com/public

     <Directory /var/www/html/mydomain.com/public>
         Options -Indexes +FollowSymLinks
         AllowOverride All
         Require all granted
     </Directory>

        ErrorLog /var/www/html/mydomain.com/logs/error.log
        CustomLog /var/www/html/mydomain.com/logs/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
</VirtualHost>
</IfModule>

Further information to help: sudo apachectl -S

VirtualHost configuration:
*:443                  is a NameVirtualHost
         default server default (/etc/apache2/sites-enabled/000-default.conf:22)
         port 443 namevhost default (/etc/apache2/sites-enabled/000-default.conf:22)
         port 443 namevhost example.com1 (/etc/apache2/sites-enabled/example.com1-le-ssl.conf:2)
         port 443 namevhost example.com2 (/etc/apache2/sites-enabled/example.com2.conf:18)
         port 443 namevhost example.com3 (/etc/apache2/sites-enabled/example.com3-le-ssl.conf:2)
                 alias example.com3
         port 443 namevhost example.com4 (/etc/apache2/sites-enabled/example.com4-le-ssl.conf:2)
         port 443 namevhost example.com5 (/etc/apache2/sites-enabled/example.com5-le-ssl.conf:2)
         port 443 namevhost example.com6 (/etc/apache2/sites-enabled/example.com6-le-ssl.conf:2)
*:80                   is a NameVirtualHost
         default server default (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost default (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost example.com1 (/etc/apache2/sites-enabled/example.com1.conf:1)
         port 80 namevhost example.com2 (/etc/apache2/sites-enabled/example.com2.conf:1)
         port 80 namevhost example.com3 (/etc/apache2/sites-enabled/example.com3.conf:1)
                 alias example.com3
         port 80 namevhost example.com4 (/etc/apache2/sites-enabled/example.com4.conf:1)
         port 80 namevhost example.com5 (/etc/apache2/sites-enabled/example.com5.conf:1)
         port 80 namevhost example.com6 (/etc/apache2/sites-enabled/example.com6.conf:1)

Any help would be much appreciated ...

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.