Lighttpd 反向代理设置
我正在尝试将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
严格来说,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?