我有一个简单的应用程序,允许您将图像上传到服务器上,它是在我的生产服务器上设置的,该服务器由django + uwsgi + ngnix组成。
我在尝试上传图片时遇到问题。我得到以下错误:
错误
502 Bad Gateway
nginx/1.2.1
功能:
def upload(request):
form = ImageForm()
context = {'form':form,}
context.update(csrf(request))
if request.POST:
form = ImageForm(request.POST, request.FILES)
if form_is.valid():
image = request.FILES.get('image')
CarPhoto.objects.create(user=request.user,cars=1,description='dwq',image=image)
return HttpResponseRedirect(reverse('transformer:kevin'))
return render_to_response('image.html',context,context_instance=RequestContext(request))
模板
<form method="POST" enctype="multipart/form-data" action=".">
{% csrf_token %}
<div id="c">image</div> {{form.image}}
<input type = "submit" value= "add" id="box2"/>
</form>
The mysite.com_error.log
"uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload"
2013/06/26 12:07:39 [error] 28870#0: *5 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload"
2013/06/26 12:08:12 [error] 29065#0: *5 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload"
2013/06/26 12:08:18 [error] 29065#0: *7 readv() failed (104: Connection reset by peer) while reading upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload"
2013/06/26 12:09:11 [error] 29065#0: *9 readv() failed (104: Connection reset by peer) while reading upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload"
2013/06/26 12:09:52 [error] 29065#0: *14 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload"
2013/06/26 12:10:51 [error] 29065#0: *19 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload"
发布于 2013-09-13 14:09:38
听起来好像您的uWSGI实例已经死了,或者失败了,它不知道如何回答。
首先,除了uWSGI日志之外,还要查看nginx日志,看看它走了多远。
也许你上传的文件太大了,会阻塞一些前端的流部分。
编辑您的帖子以指示两个日志文件的输出,我们将看到。
发布于 2014-04-22 18:42:57
如果第三方应用程序包含在您的项目中,那么它也应该安装在您的服务器上,就像南方是第三方应用程序一样。考虑settings.py文件中包含了south,那么south也应该安装在您的服务器上。如果此处考虑南向模块已安装在服务器上,请尝试升级它。因为您可能正在本地计算机上使用模块的升级版本,而在服务器上安装了较旧的版本。
https://stackoverflow.com/questions/17319896
复制相似问题