我正在运行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错误。 –