我正在運行Django,uwsgi,ngix服務器。 我的服務器對於較小尺寸的GET,POST請求正常工作。但是POST操作大尺寸的請求時,Nginx將返回502: nginx的error.log中是:sendfile()失敗(32:斷開的管道)同時向上遊發送請求nginx 502
2016/03/01 13:52:19 [error] 29837#0: *1482 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 175.110.112.36, server: server-ip, request: "POST /me/amptemp/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "servername"
因此,爲了尋找到真正的問題是,我跑uwsgi的不同端口上,如果任何錯誤校驗發生在相同的請求。但要求是成功的。所以,問題在於nginx或unix套接字配置。 NGIN-X配置:
# the upstream component nginx needs to connect to
upstream django {
server unix:///tmp/uwsgi.sock; # for a file socket
# server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name 52.25.29.179; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/usman/Projects/trequant/trequant-python/trequant/media; # your Django project's media files - amend as required
}
location /static {
alias /home/usman/Projects/trequant/trequant-python/trequant/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location/{
######## proxy_pass http://127.0.0.1:8000;
######## proxy_set_header Host $host;
######## proxy_set_header X-Real-IP $remote_addr;
######## proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_pass django;
uwsgi_read_timeout 600s;
uwsgi_send_timeout 600s;
include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
}
}
因此,任何知道我做錯了嗎?先謝謝你。
您確定您要上傳的文件低於75MB並且請求中的時間低於600秒? –
是的,我正在上傳3MB,是的,它不到600秒。事實上,nginx在30秒內響應502錯誤。 –