Lighttpd 反向代理设置

发布于 2025-01-07 06:22:11 字数 1580 浏览 2 评论 0原文

我正在尝试将 Lighttpd 配置为充当反向代理。我想要有多个 URL 代理到不同端口上的不同服务器,无论是在同一台计算机上还是在本地网络内。

例如:

/ /静止的 /插座 /ajax

Lighttpd 将代理除 /static 之外的所有连接。我想直接从该 lighttpd 实例向 /static 提供所有请求。

这是 mod_proxy 的配置文件:

##
# Serve Static Content via Lighttpd.
#
$HTTP["url"] =~ "^/static/" {
    server.document-root = "/path/to/my/static/files"
    accesslog.filename = rootdir + "/var/log/static.log"
    server.errorlog = rootdir + "/var/log/static.error.log"
}
##
# Proxy to instance of Socket.io.
#
else $HTTP["url"] =~ "^/socket/" {
    accesslog.filename = rootdir + "/var/log/socket.log"
    server.errorlog = rootdir + "/var/log/socket.error.log"
    proxy.server  = (
        "" => ( (
            "host" => "127.0.0.1",
            "port" => 3000
        ) )
    )
}
##
# Proxy to AJAX backend.
#
else $HTTP["url"] =~ "^/ajax/" {
    accesslog.filename = rootdir + "/var/log/ajax.log"
    server.errorlog = rootdir + "/var/log/ajax.error.log"
    proxy.server  = (
        "" => ( (
            "host" => "127.0.0.1",
            "port" => 4000
        ) )
    )
}
##
# Proxy to something that returns my layout.
#
else $HTTP["url"] =~ "^/" {
    accesslog.filename = rootdir + "/var/log/root.log"
    server.errorlog = rootdir + "/var/log/root.error.log"
    proxy.server  = (
        "" => ( (
            "host" => "127.0.0.1",
            "port" => 5000
            ) )
    )
}

我很确定我的正则表达式是错误的。我还认为 else 字符串是错误的。我只是不知道还能怎么做。我是这个领域的新手,所以我希望能得到一些正确方向的推动。

谢谢,

I am trying to configure Lighttpd to act as a reverse proxy. I want to have several URLs that are proxied to different servers on different ports, either on the same machine or within the local network.

For example:

/
/static
/socket
/ajax

Lighttpd would proxy all of the connections except those to /static. I want to serve all requests to /static directly from this instance of lighttpd.

Here is the config file for mod_proxy:

##
# Serve Static Content via Lighttpd.
#
$HTTP["url"] =~ "^/static/" {
    server.document-root = "/path/to/my/static/files"
    accesslog.filename = rootdir + "/var/log/static.log"
    server.errorlog = rootdir + "/var/log/static.error.log"
}
##
# Proxy to instance of Socket.io.
#
else $HTTP["url"] =~ "^/socket/" {
    accesslog.filename = rootdir + "/var/log/socket.log"
    server.errorlog = rootdir + "/var/log/socket.error.log"
    proxy.server  = (
        "" => ( (
            "host" => "127.0.0.1",
            "port" => 3000
        ) )
    )
}
##
# Proxy to AJAX backend.
#
else $HTTP["url"] =~ "^/ajax/" {
    accesslog.filename = rootdir + "/var/log/ajax.log"
    server.errorlog = rootdir + "/var/log/ajax.error.log"
    proxy.server  = (
        "" => ( (
            "host" => "127.0.0.1",
            "port" => 4000
        ) )
    )
}
##
# Proxy to something that returns my layout.
#
else $HTTP["url"] =~ "^/" {
    accesslog.filename = rootdir + "/var/log/root.log"
    server.errorlog = rootdir + "/var/log/root.error.log"
    proxy.server  = (
        "" => ( (
            "host" => "127.0.0.1",
            "port" => 5000
            ) )
    )
}

I am pretty sure that my regular expressions are wrong. I also think the else stringing is wrong. I am just not sure how else to do it. I am new to this area, so I would appreciate some nudges in the right direction.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

动次打次papapa 2025-01-14 06:22:11

严格来说,else 块应该是不必要的。

至于您的实际问题,您在问题中声明您想要匹配 /ajax,但您的正则表达式会查找 /ajax/ (注意尾部斜杠)。您请求的 URL 是什么?

Strictly speaking, the else blocks should be unnecessary.

As to your actual problem, you state in your question you want to match /ajax, but your regex looks for /ajax/ (note the trailing slash). What is the URL you are requesting?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文