从子目录请求nginx服务器上的网站

我们有两个nginx服务器。 第一台服务器通过www.example.com/partner收到请求。 他将整个请求发送到configuration了php + fastCgi的第二台服务器。 来自第二台服务器的Nginx访问日志:

“GET / partner / HTTP / 1.0”200 2845

在第二台服务器上,我有一个看起来像这样的虚拟主机

 server { listen my.ip:80; server_name www.example.com; root /var/www/example; if ($http_host != "www.example.com") { rewrite ^ http://www.example.com$request_uri permanent; } index index.php index.html; location = /partner/favicon.ico { log_not_found off; access_log off; expires max; } location @nocache { try_files $uri $uri/ /index.php?$args; } location = /partner/robots.txt { allow all; log_not_found off; access_log off; } location ^~ /partner/typo3temp/tx_ncstaticfilecache { expires 43200; charset utf-8; } location = /partner/clear.gif { empty_gif; expires max; } location ^~ /partner/typo3/gfx { expires max; } location ^~ /partner/typo3temp/compressor { expires max; } location /partner { if ($query_string ~ ".+") { return 405; } # pass requests from logged-in users to PHP if ($http_cookie = 'nc_staticfilecache|be_typo_user' ) { return 405; } # pass POST requests to PHP if ($request_method !~ ^(GET|HEAD)$ ) { return 405; } if ($http_pragma = 'no-cache') { return 405; } if ($http_cache_control = 'no-cache') { return 405; } error_page 405 = @nocache; # serve requested content from the cache if available, otherwise pass the request to PHP try_files /typo3temp/tx_ncstaticfilecache/$host${request_uri}index.html @nocache; location ~* \.(sql|htaccess|htpasswd|tpl|html5|xhtml) { deny all; } location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ { expires max; log_not_found off; } location ~* \.(cur|ico|gif|png|jpe?g|css|js|swf|woff)((\?\d\d\d\d\d\d\d\d\d\d)|(\?s=\d\d\d\d\d\d\d\d\d\d))$ { expires max; log_not_found off; } location ~* \.(cur|ico|gif|png|jpe?g|css|js|swf|woff)(\?v\d\d?\.\d\d?\.\d\d?)$ { expires max; log_not_found off; } location ~* ^(/typo3/sysext|/typo3conf/ext).*\.(cur|ico|gif|png|jpe?g|css|js|swf|woff) { expires max; log_not_found off; } location ~ /\. { deny all; access_log off; log_not_found off; } location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; } } } 

index.php不被解释的问题,而是被下载。 任何想法什么是错的?

你的configuration和这个很相似,你明显缺less的部分是try_files $uri $uri/ /index.php?$args;server块的根目录中。

另一个build议是尝试使用完全一样的链接configuration,以确保一切正常,这不是由您的location / ifs造成的。 之后包括error_log ~/nginx_debug.log info;server块中进行更改 – 您将能够了解configuration的哪个部分已损坏。