問題描述
lighttpd:身份驗證後如何將端口(僅對本地主機可見)轉發到 WAN? (lighttpd: How to forward port (visible only to localhost) to WAN after authentication?)
我有一個只能在主機上通過 http://localhost:1234
這個流沒有身份驗證。
我想設置一個輕量級的http服務器,在80端口監聽外部連接,提示輸入用戶名和密碼,然後從localhost:1234
我該怎麼做這個?
參考解法
方法 1:
Lighttpd can do this. The following config files will forward requests to http://domain.com/ => http://localhost:1234/ requesting a http basic auth first.
lighttpd.conf
## Add auth and proxy mods to your existing modules list
server.modules = (
"mod_auth",
"mod_proxy"
)
$HTTP["host"] == "domain.com" {
auth.backend = "plain"
auth.backend.plain.userfile = "lighttpd‑plain.user"
auth.require = (
"/" => (
"method" => "basic",
"realm" => "MyWebcam",
"require" => "valid‑user"
)
)
proxy.server = (
"/" => (
(
"host" => "127.0.0.1",
"port" => 1234
)
)
)
}
lighttpd‑plain.user
webcamuser:webcampassword
Make sure you load mod_auth
before mod_proxy
in server.modules
, getting them in the wrong order can make lighty panic.