處理具有多行的Excel文件時出現錯誤502。處理具有多行的Excel文件時出現錯誤502
使用Django/Nginx的
的問題是不是文件的重量小於1MB。
本頁對200行文件正常工作,問題在文件有更多行時開始,然後頁面花費太長的時間處理此文件。
這是錯誤:
2012/07/28 14:29:54 [error] 18515#0: *34 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST /import/ HTTP/1.1", upstream: "http://127.0.0.1:9000/import/", host: "localhost:8080", referrer: "http://localhost:8080/import/"
我使用非常大的值的變量,但我不斷收到同樣的錯誤。
這是網站的配置:
upstream app_server {
server 127.0.0.1:9000 fail_timeout=3600s;
keepalive 3600s;
}
server {
listen 8080;
client_max_body_size 4G;
server_name localhost;
keepalive_timeout 3600s;
client_header_timeout 3600s;
client_body_timeout 3600s;
send_timeout 3600s;
location /static/ {
root /my path/;
autoindex on;
expires 7d;
}
location /media/ {
root /my path/;
autoindex on;
expires 7d;
}
location/{
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
}
這是全局配置:
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 3600s;
tcp_nodelay on;
client_header_timeout 3600s;
client_body_timeout 3600s;
send_timeout 3600s;
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
client_max_body_size 200m;
client_body_buffer_size 128k;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
燦你給我一些幫助?
問候
TBH你笑這可能是django-celery這樣的服務器端任務。 – 2012-07-28 19:43:20
像Django這樣的聲音處理文件比nginx期待的要長,所以它不會等待gunicorn返回Django響應。 **或**它崩潰了。你的Django代碼是否記錄任何異常?假設這是一個超時,我期望看到一個504,而不是一個502. – 2012-07-28 21:05:32
上游過早關閉連接意味着錯誤在後端。 – VBart 2012-07-30 11:53:33