lighttpd:如何在身份验证后将端口(仅对本地主机可见)转发到 WAN?

lighttpd: How to forward port (visible only to localhost) to WAN after authentication?

我有一个网络摄像头流只能通过 http://localhost:1234

在主机上访问

此流没有身份验证。

我想设置一个轻量级的 http 服务器,它在端口 80 上侦听外部连接,提示输入用户名和密码,然后转发来自 localhost:1234

的流

我该怎么做?

Lighttpd 可以做到这一点。 以下配置文件会将请求转发给 http://domain.com/ => http://localhost:1234/,首先请求 http 基本身份验证。

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

确保在 server.modules 中的 mod_proxy 之前加载 mod_auth,以错误的顺序加载它们可能会导致轻度恐慌。