在最近的 Ubuntu 更新之后,我的本地网站不再通过 SSL 提供其页面。例如,我的 .htaccess 文件尝试确保 /sign-in 始终通过 HTTPS 提供:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /sign-in
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,QSA,R=301]
但是,当我在域 site2-local 上向 /sign-in 发出请求时,出现错误“该页面未正确重定向”,其中/var/log/apache2/error.log
[Tue Jun 08 12:20:57 2010] [info] [client 127.0.1.1] Connection to child 0 established (server site1-local:443)
[Tue Jun 08 12:20:57 2010] [info] Seeding PRNG with 656 bytes of entropy
[Tue Jun 08 12:20:57 2010] [info] Initial (No.1) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.2) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.3) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.4) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.5) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.6) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.7) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.8) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.9) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:20:57 2010] [info] Subsequent (No.10) HTTPS request received for child 0 (server site2-local:443)
[Tue Jun 08 12:21:12 2010] [info] [client 127.0.1.1] (70007)The timeout specified has expired: SSL input filter read failed.
[Tue Jun 08 12:21:12 2010] [info] [client 127.0.1.1] Connection closed to child 0 with standard shutdown (server site2-local:443)
有一个与 site1-local(我的机器上共享证书的另一个站点)的连接,我不明白。
有人知道是什么导致了这个问题吗?
答案1
我不知道是什么导致了这个问题,但不久前我自己遇到了这个问题,并找到了一种使用不同变量来检测 https 请求的解决方法。
%{SERVER_PORT}
您可以使用或之一%{SERVER_PROTOCOL}
。
这也可能是一个大写问题。 %{HTTPS}
可能是“Off”而不是“off”。
在我的 SSL VirtualHosts 中,我有SetEnv HTTPS on
一个解决方案,可以解决我遇到的另一个问题,但应该也能解决您的问题。需要此解决方案的最终原因是变量%{HTTPS}
未正确设置。如果您的%{HTTPS}
变量未设置,则手动设置它应该可以解决问题。
答案2
我认为当 SSL 未打开时,HTTPS 可能并不总是设置。因此测试端口确实是一个很好的解决方案 (%{SERVER_PORT})
答案3
首先让我们确保 apache 是否正在监听 https 端口:
lsof -i:443
如果您发现没有输出,那么问题就出在 SSL 模块而不是重写规则上,特别是因为您说相同的规则在升级之前运行正常。
还请验证运行apache2ctl -t
是否没有错误或警告