2

I am trying to configure apache virtual host for ssl.

mywebsite.conf

<VirtualHost *:80>
        ServerAdmin info@mywebsite.com
        ServerName mywebsite.com
        ServerAlias www.mywebsite.com

        DocumentRoot /opt/tomcat/webapps/mywebsite
        <Directory /opt/tomcat/webapps/mywebsite>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined[L,NE,R=permanent]
</VirtualHost>

mywebsite-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin info@mywebsite.com
        ServerName mywebsite.com
        ServerAlias www.mywebsite.com

        DocumentRoot /opt/tomcat/webapps/mywebsite
        <Directory /opt/tomcat/webapps/mywebsite>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLEngine on
        SSLCertificateFile /certs/mywebsite_ssl_certificate.crt
        SSLCertificateKeyFile /certs/_.mywebsite_private_key.key
        SSLCertificateChainFile /certs/_.mywebsite_ssl_certificate_INTERMEDIATE.crt
</VirtualHost>
</IfModule>

I enabled both of sites with a2ensite command.

And disabled all other sites.

Also mod ssl is enabled.

/etc/hosts file looks like this:

# nameserver config
# IPv4
127.0.0.1 localhost
127.0.0.1 mywebsite.com
#
# IPv6
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

And if I try access to http://mywebsite.com via browser I am able to see my application. But if I try access to https://mywebsite.com via browser, there is an error:

this site can’t be reached the webpage at might be temporarily down or it may have moved permanently to a new web address

I need help where could be a mistake in my configuring.

slava
  • 4,085
Ante Ereš
  • 121
  • 1
  • 3

1 Answers1

0

Your configurations seem fine. However, it seems that Apache may not be listening to the 443 port.

You may need to instruct Apache to listen to that port by adding the following to a config file.

Listen 443

The line should exist outside a <VirtualHost> tag.

You easily try it by adding to the top of the mywebsite-ssl.conf file or have a standalone config file for it.

If you are using Apache 2.4:

echo "Listen 443" | sudo tee /etc/apache2/conf-available/ssl-port.conf
sudo a2enconf ssl-port
# I'm not sure if graceful will be enough here
# you may need to fully restart the apache2 service
sudo apache2ctl restart 
Dan
  • 14,180