So for posterity sake, I am trying to configure my server so that even when someone tries to go to go to http:// domain.com:443, they would be correctly redirected to the https version of the site (https:// domain.com).
When testing something like http:// domain.com:443, it does not redirect correctly to https:// domain.com, I instead get hit with a 400 Bad Request page with the following content:
Bad Request
Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please.
Apache/2.4.18 (Ubuntu) Server at sub.domain.com Port 443
I tried including the following lines in my 000-default.conf in the <VirtualHost *:80>:
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] But it didn't work.
This issue occurs on all domains, subdomains and the server IP itself.
Possibly related, trying to do a dry run of letsencrypt returns the following:
Domain: domain.com Type: connection Detail: Failed to connect to 123.123.123.123:443 for TLS-SNI-01 challenge For each and every domain listed in the sites-enabled folder.