Python

Lighttpd $HTTP“霍斯特”___‘H這s噸’‘host’正則表達式匹配

  • April 2, 2012

我已經像這樣設置了我的配置:

$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 時,一切都按預期工作。為什麼域匹配會這樣失敗?

您已將兩個 fastCGI 伺服器設置為使用相同的套接字文件。很可能只有第一個被成功創建,並且所有事務都進入該套接字並輸出到同一個 Python 腳本。

引用自:https://serverfault.com/questions/376039