![Lighttpd $HTTP["host"] 正则表达式匹配](https://linux22.com/image/580428/Lighttpd%20%24HTTP%5B%22host%22%5D%20%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%8C%B9%E9%85%8D.png)
我已经像这样设置了我的配置:
$HTTP["host"] =~ "(^|\.)domain1\.com$" {
fastcgi.server = ( "/domain1.py" =>
((
"socket" => "/tmp/fastcgi.socket",
"bin-path" => "/home/domain1/serveV03.py",
"max-procs" => 1,
"bin-environment" => (
"REAL_SCRIPT_NAME" => ""
),
"check-local" => "disable"
))
)
server.document-root = "/home/domain1"
url.rewrite-once = (
"^/favicon.ico$" => "/static/favicon.ico",
"^/static/(.*)$" => "/static/$1",
"^/(.*)$" => "/domain1.py/$1"
)
}
$HTTP["host"] =~ "(^|\.)domain2\.com$" {
fastcgi.server = ( "/domain2.py" =>
((
"socket" => "/tmp/fastcgi.socket",
"bin-path" => "/home/domain2/serveV01.py",
"max-procs" => 1,
"bin-environment" => (
"REAL_SCRIPT_NAME" => ""
),
"check-local" => "disable"
))
)
server.document-root = "/home/domain2"
url.rewrite-once = (
"^/favicon.ico$" => "/static/favicon.ico",
"^/static/(.*)$" => "/static/$1",
"^/(.*)$" => "/domain2.py/$1"
)
}
但不知何故,当我访问 domain2.com 时,domain1.py 启动了 - 奇怪的是 /static/ 中的内容被正确地从 /home/domain2/static 中提取。
当我输入 domain1.com 时,一切都按预期进行。为什么域名匹配会这样失败?
答案1
您已将两个 fastCGI 服务器设置为使用同一个套接字文件。很可能只有第一个服务器成功创建,并且所有事务都进入该套接字并输出到同一个 Python 脚本。