【发布时间】:2014-01-29 11:09:17
【问题描述】:
我想将子域重定向到 https(当请求到达 http 时),但不是全部。 我正在使用 FuelPHP,我正在清理 url,以便 index.php 不可见。 我写了这个配置,但没有按预期工作。 HTTPS 请求正在通过,但是当使用 HTTP 请求时,服务器无法发送应答。
$HTTP["host"] !~ "^(demo|faq|help|forums|mail|www)\.(domain\.com)$" {
$HTTP["host"] =~ "^(.+\.)?(domain\.com)$" {
$SERVER["socket"] == ":80" {
url.redirect = ( "^/(.*)" => "https://%1/$1" )
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/certs/domain.com.pem"
}
server.document-root = "/home/domain/beta/public"
server.errorlog = "/var/log/lighttpd/domain/beta/error.log"
accesslog.filename = "/var/log/lighttpd/domain/beta/access.log"
setenv.add-environment = ("FUEL_ENV" => "production")
url.rewrite-once = (
"/(.*)\.(.*)" => "$0",
"/(js|ico|gif|jpg|png|swf|css|html)/" => "$0",
"^/([^.]+)$" => "/index.php/$1")
server.error-handler-404 = "/index.php"
}
}
我有一些从一开始就被过滤的子域(演示、常见问题、...)的特定配置。 所有未过滤的子域都由应用程序动态管理,因此必须保持可访问性,但只能在 SSL 下访问。
【问题讨论】:
-
你说“服务器发送应答失败”,这是什么意思?如果你请求一个 http 页面,服务器会返回什么?另外,您是否阅读过 lighttpd http to https 文档?
-
我使用 Chrome Inspect Element 追踪并记录了网络活动。有一个来自浏览器的请求在使用 HTTP 时处于待处理状态,而在使用 HTTPS 时完全得到答复
标签: configuration https lighttpd