Apache sends plain-text response when accessing SSL-enabled site without HTTPS
Solution 1:
First: With Apache you cannot have HTTPS and HTTP running on the same port.
See: Apache answer both HTTP and HTTPS on the same port
For handling both SSL and non-SSL traffic you have to define two virtual hosts.
See: Redirect http to https apache on different port
For the redirect from non-SSL virtual host to SSL virtual host we use this:
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^(.*)/? https://%1$1 [L,R]
</VirtualHost>
Remains the problem that explicitly sending a non-SSL request to the SSL-enabled port ( http://mydomain.com:443/ ) gives the:
You're speaking plain HTTP to an SSL-enabled server port
page as plain text (in a Firefox browser). Explicitly sending a SSL request to the non-SSL port ( https://mydomain.com:80/ ) gives a:
ssl_error_rx_record_too_long error
(in the Firefox browser).
Why is this occurring?