【发布时间】:2019-01-15 17:36:27
【问题描述】:
我有一台在 HTTPS 上运行的 Lighttpd 服务器,我希望服务器上的一个子目录充当在 HTTP 上运行的单独服务器的反向代理。我已尝试遵循有关进行代理和 url 重写的指南,但与 SSL 的设置方式有关的事情会产生干扰。
$SERVER["socket"] == ":81" {
url.rewrite-once = ( "^/directory/(.*)$" => "/index.html" )
proxy.server = ( "" => ( "" => ( "host" => "192.0.0.1", "port" => 123 )))
}
$HTTP["scheme"] == "http" {
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.ca-file = "/etc/lighttpd/fullchain.pem"
ssl.pemfile = "/etc/lighttpd/server.pem"
$HTTP["url"] =~ "^/directory/" {
proxy.server = ( "" => ( "" => ( "host" => "127.0.0.1", "port" => 81)))
}
}
我的意图是转到 /directory/ 会将您重定向到 192.0.0.1:123/index.html。我关注了this guide,其中提到了第一次重定向到端口 81,然后将端口 81 重定向到第二个服务器。
这似乎不起作用,只是卡在重定向循环中,并且总是向 https 站点返回 301。
如果我不执行 :81 重定向,我可以让底部的 proxy.server 重定向到正确的位置,但它会保留 /directory/ 结尾,而我无法到达我需要的位置。
谢谢。
【问题讨论】:
标签: https reverse-proxy lighttpd mod-proxy