NGINX server_name问题

我在NGINX上有以下简单的服务器块:

server { listen 80; listen 8090; server_name domain.com; autoindex on; root /home/docroot; location ~ \.php$ { include /usr/local/nginx/conf/fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/docroot$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } } 

在我的主机文件中包含相关设置后,出现以下(意外)行为:

  1. http://domain.com/和http://domain.com:8090/正常工作;
  2. http://domain.com:8090/future-cell-phone-technology-01-150×150.jpg作品;
  3. http://domain.com/future-cell-phone-technology-01-150×150.jpg – >错误! “连接被重置”

(注意 – 在http后面添加一个空格,以避免链接保护,但这并不是真正的促销)

我已经排除故障(3)几个小时,我无法确定罪魁祸首。 我在Debian 6.0.2 32位上运行了NGINX 1.0.10(最新版本)。

这NGINX实例运行另外40或50个站点没有问题。

也许你需要使用try_files指令,因为你似乎有服务静态文件(.jpg和其他graphics,CSS等),但不是PHP文件的问题。

来自NGginx wiki的drupal示例configuration:

 # for Drupal 6 or 7: try_files $uri $uri/ /index.php?q=$uri&$args; # a better version for Drupal 7 since it doesn't need q=$uri: try_files $uri $uri/ /index.php?$args; location ~ \.php$ { fastcgi_pass 127.0.0.1:8888; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # if not already defined in the fastcgi_params file # any other specific fastcgi_params } 

有关更多详细信息,请参阅: http : //wiki.nginx.org/HttpCoreModule#try_files

所以给你的configuration,也许简单地添加try_files指令会像这样工作(未testing)?

 server { listen 80; listen 8090; server_name domain.com; autoindex on; root /home/docroot; try_files $uri $uri/ /index.php?$args; location ~ \.php$ { include /usr/local/nginx/conf/fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/docroot$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } }