I have successfully installed SSL certificate with certbot and lets encrypt on my debian and apache linux virtual machine on google cloud.
the domain is successfully secure with HTTPS.
Although on directly accessing the external ip address i am still getting an unsecure version of the website. How to redirect the ip directly to the HTTPS version set up with APACHE and just the "domain.com" towards -->> HTTPs:www.domain.com .
I have tried to re-route to port 80 and 443 towards the HTTPS version as in PHP without any luck as shown here : How to redirect from www to https www with htacces?
in my 000-default.conf:
<VirtualHost *:80> ServerName localhost ServerAdmin webmaster@localhost ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined RewriteEngine on RewriteCond %{SERVER_NAME} =www.bracketline.com [OR] RewriteCond %{SERVER_NAME} =localhost RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost> and on my 000-default-le-ssl.conf i have:
<IfModule mod_ssl.c> <VirtualHost *:443> ServerName localhost ServerAdmin webmaster@localhost Alias /static /var/www/static-root <Directory /var/www/static-root> Require all granted </Directory> Alias /media /var/www/media-root <Directory /var/www/media-root> Require all granted </Directory> <Directory /var/www/venv/src/cfehome> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess cfehome python- path=/var/www/venv/src/:/var/www/venv/lib/python3.5/site-packages WSGIProcessGroup cfehome WSGIScriptAlias / /var/www/venv/src/cfehome/wsgi.py ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined ServerAlias www.bracketline.com SSLCertificateFile /etc/letsencrypt/live/www.bracketline.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/www.bracketline.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule> I am not sure how this thing works if a detailed blog or turorial could be given it would be of great help. thanx in advance!