I’ve been searching far and wide and can’t seem to find the solution. When I used the xxxx.ddns.net url, all requests were automatically redirected to https without issue. Now I made a new cert with my new domain xxxx.com and all requests are being sent to http://xxxx.com. https://xxxx.com work as well. I use a LAMP stack with nextcloud running on that (xxxx.com/nextcloud) and I have a regular website I use to play around w/ css/php stuff (xxxx.com).
Any ideas why this started when changing url’s? Thank you!
Hi,
Did you activate the HTTPS redirect in dietpi-letsencrypt while creating the certificate?
Yup that option was checked
Can you post the content of the port 80 vhost (which should contain the redirect/rewrite to HTTPS):
cat /etc/apache2/sites-available/000-default.conf
Remove any identifying strings, like hostnames, if present.
It’s working now. My 443 and 80 sections are flipped so I had a user error. This is what’s working if anybody stumbles across the problem.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName xxxx.com
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias xxxx.com
SSLCertificateFile /etc/letsencrypt/live/xxxx.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxx.com/privkey.pem
RewriteEngine on
RewriteCond "%{HTTP_HOST}%{REQUEST_URI}" "^xxxx\.com\/?$"
RewriteRule .* https://xxxx.com
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName xxxx.com
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
</IfModule>
Okay great. Aren’t 80 and 443 vhosts in different config files by default, 000-default.conf and 000-default-le-ssl.conf ?