0
votes

I'm using Let's Encrypt for my domain. I created config for example.com, www.example.com, app.example.com The example.com and www.example.com are working fine and they are pointing to /var/www/html, but the app.example.com is always redirecting to example.com which is supposed to point to /var/www/app

Here is my ssl.conf

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch    "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/example.com-0001/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example.com-0001/privkey.pem
    </VirtualHost>

     <VirtualHost *:443>
                ServerAdmin webmaster@localhost
                ServerName app.example.com
                DocumentRoot /var/www/app
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
        <Directory /var/www/app>
                  Order allow,deny
                  allow from all
        </Directory>

                BrowserMatch    "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
                BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
                Include /etc/letsencrypt/options-ssl-apache.conf
                SSLCertificateFile /etc/letsencrypt/live/app.example.com/fullchain.pem
                SSLCertificateKeyFile /etc/letsencrypt/live/app.example.com/privkey.pem
        </VirtualHost>
</IfModule>

I am confused about what has missed here!

1

1 Answers

0
votes

The problem is fixed. The subdomain was set on 2 different certificates, so when I generated a separate certificate only for the subdomain, the problem is solved.