Question

Subdomain SSL problem

Posted March 23, 2018 661 views
Ubuntu Apache

Hello,

I hosted my subdomain on my Ubuntu server running apache2 2.4
However I wan’t the subdomain to be reached over HTTPS however I can only reach it over HTTP when i try HTTPS it just redirects to my main site.

My host file:

code
sites-available# cat sub.redacted.conf
<VirtualHost *:80>
    ServerAdmin root@localhost
    ServerName sub.redacted.com
    ServerAlias www.sub.redacted
    DocumentRoot /var/www/subdomain

    <Directory /var/www/xmrfront>
       Options Indexes FollowSymLinks
       AllowOverride None
       Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
                ServerAdmin root@localhost
                ServerName sub.redacted.com
                ServerAlias www.sub.redacted.com
                DocumentRoot /var/www/subdomain
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLCertificateFile      /root/keys/pub.crt
                SSLCertificateKeyFile   /root/keys/priv.key
                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
        </Directory>
</VirtualHost>

And then there’s also the default-ssl.conf file for my main site SSL which looks like this:

#cat default-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
                ServerAdmin root@localhost
                ServerName mainredacted.com
                DocumentRoot /var/www/html
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLCertificateFile      /root/keys/pub.crt
                SSLCertificateKeyFile   /root/keys/priv.key
                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
        </VirtualHost>
</IfModule>

Any thoughts ?
I’m using cloudflare and i’m not doing anything weird like redirecting http or something.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Hello,

The VirtualHost configuration for your subdomain name for port 443 actually looks correct, have you restarted your Apache service after you made the change to the configuration file?

Regards,
Bobby

Submit an Answer