Having trouble getting auto redirect from http to https to work.
First time a user visits anonstv.com, it goes to http://anonstv.com. But if that same user then visits https://anonstv.com, it will auto redirect them to the https one in future, I believe that is due to HSTS.
The http one just shows the servers phpinfo page instead of showing the website content.
Domain: anonstv.com
Hosting: Hostinger VPS
OS: Ubuntu 18.04
Certbot: 0.27.0
Command used to create certificate:
sudo certbot --apache --agree-tos --redirect --uir --hsts --staple-ocsp --must-staple -d www.anonstv.com, anonstv.com --email email@email.com
/etc/apache2/sites-available/
<VirtualHost *:443>
ServerAdmin admin@anonstv.com
ServerName anonstv.com
ServerAlias www.anonstv.com
DocumentRoot /var/www/anonstv.com<Directory /var/www/anonstv.com>
Options FollowSymLinks
AllowOverride all
Require all granted
ErrorLog ${APACHE_LOG_DIR}/error.log
SSLStaplingCache shmcb:/var/run/apache2/stapling_cache(128000)
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine On
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.anonstv.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.anonstv.com/privkey.pem
Header always set Strict-Transport-Security "max-age=31536000"
SSLUseStapling on
Header always set Content-Security-Policy upgrade-insecure-requests
/etc/apache2/sites-available/le-redirect-anonstv.com.conf
<VirtualHost *:80>
ServerName anonstv.com
ServerAlias www.anonstv.com
ServerSignature OffRewriteEngine On
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]ErrorLog /var/log/apache2/redirect.error.log
LogLevel warn
/var/www/anonstv.com/.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} anonstv.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://anonstv.com/$1 [R,L]
.
.
Note: It seems like the http version of the site completely skips over reading the conf files, and skips over .htacces, and just resolves to the servers IP address. I have set this all up on 2 domains now on the server with the same result.
Other domains that I have cloudflare ssl on are working fine.
Allow Override is set to All aswell.