I have a strange problem where Apache2 is working correctly for some time and later than I test http://example.com it's not auto-redirecting to SSL anymore.
(to be clear - the foolowing problem is only about one virtualhost that is supposted to redirect to https version of the service, https version of the website is working correctly)
Nothing helps, restarting the host, restarting apache2 and whatnot.
This is my config for the http virtualhost:
<VirtualHost x.x.x.x:80>
ServerName example.com
ServerAlias www.example.com
ServerSignature Off
DocumentRoot /var/www/non-ssl
Redirect permanent / https://example.com/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
<Directory />
Options All
AllowOverride All
Order deny,allow
Allow from all
</Directory>
Redirect / https://example.com/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogLevel warn
</VirtualHost>
I've even put this index.html into /var/www/non-ssl
<meta http-equiv="refresh" content="0; url=https://example.com/" />
And every time I enter http://example.com it gives me 403 Forbidden.
Forbidden
You don't have permission to access / on this server.
Permissions for the index.html file are the following:
-rw-r--r-- 1 root root 69 Jun 5 18:07 index.html
The OS is debian stable.
P.S
I am aware of duplicate of Redirect
statement in the virtualhost config, but that doesn't matter which of these thing I'll there, it's all the same, always 403.
EDIT: It appears that connecting to http://www.example.com redirects to https://www.example.com But connecting to http://example.com throws 403. I even restarted (stopped and started the service) apache to see if this issue is still present on http://example.com and it is still present.