Lighttpd的反向代理服务器设置 [英] Lighttpd Reverse Proxy Settings
问题描述
我想Lighttpd的配置,作为一个反向代理。我想有一个代理到不同的服务器上的不同端口数的网址,或者在同一台计算机或本地网络中。
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.
例如:
/ /静 /插座 / AJAX
/ /static /socket /ajax
lighttpd的会代理,除了那些以 /静态
的连接。我想为所有请求 /静态
直接从lighttpd的实例中。
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.
下面是mod_proxy的配置文件:
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
) )
)
}
我是pretty的肯定,我的普通恩pressions是错误的。我也觉得其他
穿线是错误的。我只是不知道怎么回事,要做到这一点。我是新来这方面的,所以我会AP preciate在正确的方向上迈出了蹭。
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.
谢谢
推荐答案
严格地说,否则块应该是不必要的。
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?
这篇关于Lighttpd的反向代理服务器设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!