试图让nginx使用X-Accel-Redirect头文件。 我得到这个错误:
*24 rewrite or internal redirection cycle while internally redirecting to "/app/index.php", client: 127.0.0.1, server: project.dev, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "project.dev"
nginx网站conf:
server { listen 80; server_name project.dev; root /www/project; location ^~ /f/ { internal; alias /www/project/files/; } location / { try_files $uri /app/index.php$is_args$args; } include php.conf; include apache.conf; }
/www/project/app/index.php
<?php header('X-Accel-Redirect: /f/image.jpg'); exit;
我加了^~到位置块,因为我认为会终止位置块的匹配,因此解决了这个问题。 这可能是我的一个误解。
任何想法如何解决这个问题?
用php.conf和apache.conf更新
php.conf:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
的apache.conf:
# deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; }
你还没有告诉nginx要找什么索引文件。
尝试添加
index index.php;
根指令后。
看起来像我没有重新启动我的nginx服务器。 几天后我回到这里,突然发现,我意识到它必须在重新启动之后。 对不起,浪费你的时间。
现在,如果我只能让它发送正确的Content-type标题..