這是nginx的我的「內部」的設置:Nginx的:X-加速重定向內部不工作
location /issues/ {
root /home/some_user/some_project/;
internal;
}
當我註釋掉「內部」的一部分,Nginx的服務於文件中的「問題」文件夾中並在其中的文件就好了。但是,即使當它啓用我仍然無法從Python或PHP代碼提供任何文件:
# Python, outputs an empty zip
import os
file_name = '12.pdf.zip'
response = HttpResponse()
response['Content-Disposition'] = 'attachment; filename=%s' % t_str(file_name)
response['Content-Length'] = os.path.getsize(file_path)
response['Content-Type'] = "application/zip"
response['X-Accel-Redirect'] = '12.pdf.zip'
return response
# PHP, does nothing
header("X-Accel-Redirect: 12.pdf.zip");
這些都是/ default和nginx.conf啓用的站點 - 。 8000是爲Django和81是爲PHP
server {
listen 80; ## listen for ipv4
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
location/{
# proxy/requests to apache running django on port 8081
proxy_pass http://127.0.0.1:8000/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location /issues/ {
root /home/some_user/some_project/;
internal;
}
}
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
# include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
include /etc/nginx/sites-enabled/*;
}
我試着改變Nginx配置爲別名,同樣的事情。並嘗試了所有可能的文件路徑。任何人都可以看到有什麼不對?或者給我一些指點?謝謝。
謝謝,但我也嘗試過。 – Asdf 2011-04-05 12:02:37