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.
</IfModule>
at the end instead of<IfModule>
. Reloading may have been skipped since it found an error in the config. You can try runningapachectl configtest
to validate the configs. – Dan Feb 19 '19 at 15:24chmod 700 /certs
andchmod 600 /certs/*
. – pa4080 Feb 19 '19 at 16:07