Nginx目录别名错误地传递给fcgi

我有一个网站虚拟主机,example.com,这是静态服务的/ home / erealms / www。

但是,该网站通过一系列perl脚本运行,这些脚本位于各种目录中。 所以我想要做的是以下几点:

http://example.com/ -> /home/erealms/www http://example.com/erealms -> /home/erealms/ethereal/main http://example.com/erealms/admin -> /home/erealms/ethereal/mgmt/admin http://example.com/erealms/config -> /home/erealms/ethereal/mgmt/config 

在除http://example.com/之外的所有目录中,将会有通过fcgiwrapper提供的perl文件.pl。

这是我目前的configuration:

 server { add_header Cache-Control public; access_log /var/log/nginx/access.log main buffer=32k; error_log /var/log/nginx/error.log error; expires max; limit_req zone=gulag burst=200 nodelay; listen 80; server_name example.com; index index.html index.htm default.html default.htm; root /home/erealms/www; location ~* (\.jpg|\.png|\.css)$ { if ($http_referer !~ ^(http://rpn.ishikawa.sne.jp) ) { return 405; } } location = /favicon.ico { return 204; } location /erealms/config { root /home/erealms/ethereal/mgmt/config/; gzip off; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:8000; fastcgi_param SCRIPT_FILENAME /home/erealms/ethereal/mgmt/config$fastcgi_script_name; } location /erealms/admin { root /home/erealms/ethereal/mgmt/admin/; gzip off; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:8000; fastcgi_param SCRIPT_FILENAME /home/erealms/ethereal/mgmt/admin$fastcgi_script_name; } location /erealms { alias /home/erealms/ethereal/main; gzip off; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:8000; fastcgi_param SCRIPT_FILENAME /home/erealms/ethereal/main$fastcgi_script_name; } } 

你会注意到我有root和alias指令,因为我试图弄清楚到底发生了什么。 这是奇怪的,但。 我在下面列出了要求的目录,以及nginx告诉fcgiwrapper访问它们的地方:

 http://example.com/erealms -> /home/erealms/ethereal/main/erealms http://example.com/erealms/admin -> /home/erealms/ethereal/mgmt/admin/erealms/admin http://example.com/erealms/config -> /home/erealms/ethereal/mgmt/config/erealms/config 

现在暂且只为了让这个该死的东西为进一步的testing工作,我刚刚创build了一个懒惰的符号链接,指向它们应该在的地方,但显然这不是一个非常优雅的解决scheme。 如果有人能指出我正确的方向来修复这个当前的设置工作,或者如果你也许有一个更好的解决scheme这个configuration的想法,我将非常感激。

不知道如何回答自己的问题在SF上,但这是我最终做的:

 server { add_header Cache-Control public; access_log /var/log/nginx/access.log main buffer=32k; error_log /var/log/nginx/error.log error; expires max; limit_req zone=gulag burst=200 nodelay; listen 80; server_name rpn.ishikawa.sne.jp; root /home/erealms/www; index index.html; location ~* (\.jpg|\.png|\.css)$ { if ($http_referer !~ ^(http://rpn.ishikawa.sne.jp) ) { return 405; } } location = /favicon.ico { return 204; } location ~ /erealms/config(/.*\.pl)$ { alias /home/erealms/ethereal/mgmt/config; gzip off; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/tmp/cgi.sock; fastcgi_param SCRIPT_FILENAME /home/erealms/ethereal/mgmt/config/$1; } location ~ /erealms/admin(/.*\.pl)$ { alias /home/erealms/ethereal/mgmt/admin; gzip off; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/tmp/cgi.sock; fastcgi_param SCRIPT_FILENAME /home/erealms/ethereal/mgmt/admin/$1; } location ~ /erealms(/.*\.pl)$ { alias /home/erealms/ethereal/main; gzip off; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/tmp/cgi.sock; fastcgi_param SCRIPT_FILENAME /home/erealms/ethereal/main/$1; } } 

现在不幸的是,这导致了一些其他的错误,我最终只会使用一个apache后端为nginx前端提供dynamic内容,但是我认为我会在这个事件中遇到类似的问题。