502 Bad Gateway Django [英] 502 Bad Gateway Django

查看:445
本文介绍了502 Bad Gateway Django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序,允许您将图像上传到服务器上,并将其设置在由django + uwsgi + ngnix组成的生产服务器上。



尝试上传图片时出现问题。我收到以下错误:



错误

  502 Bad Gateway 
nginx / 1.2.1

功能:



$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ csrf(request))


如果request.POST:
form = ImageForm(request.POST,request.FILES)
如果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))
pre>

模板

 < form method =POSTenctype =multipart / form-dataaction =。> 

{%csrf_token%}
< div id =c> image< / div> {{form.image}}
< input type =submitvalue =addid =box2/>
< / form>

mysite.com_error.log

 uwsgi:// unix:///tmp/mysite.com.sock:,host:174.414.14.551,referrer:http://174.414.14.551/car/上传
2013/06/26 12:07:39 [错误] 28870#0:* 5 sendfile()失败(32:断管)同时向上游发送请求,客户端:313.19.220.424,服务器:mysite .com,请求:POST / car / HTTP / 1.1,上游: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()失败(32:断管)同时向上游发送请求,客户端:313.19.220.424,server:mysite.com,request:POST / car / HTTP / 1.1,上游:uwsgi:// unix:///tmp/mysite.com.sock:,host:174.414。 14.551,引用:http://174.414.14.551/car/upload
2013/06/26 12:08:18 [错误] 29065#0:* 7 readv()失败(104:连接重置通过对等)同时阅读上游,客户端:313.19.220.424,服务器:mysite.com,请求:POST / car / HTTP / 1.1,上游: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()失败(104:由对等体重新连接)在上游读取时,客户端:313.19.220.424,服务器:mysite。 com,请求:POST / car / HTTP / 1.1,上游: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()失败(32:断管)同时向上游发送请求,客户端: 313.19.220.424,server:mysite.com,request:POST / car / HTTP / 1.1,上游:uwsgi:// unix:///tmp/mysite.com.sock:,host:174.414.14.551 ,引用:http://174.414.14.551/car/upload
2013/06/26 12:10:51 [错误] 29065#0:* 19 sendfile()失败(32:断管)同时发送请求到上游,客户端:313.19.220.424,服务器:mysite.com,请求:POST / car / HTTP / 1.1,上游:uwsgi:// unix:///tmp/mysite.com.sock: 主持人:174.414.14.551,参考网址:http://174.414.14.551/car/upload


解决方案

如果您的项目中包含第三方应用程序,那么它应该安装在您的服务器上,也就像南方是第三方应用程序。
考虑南方包含在您的settings.py文件中,然后南方也应该安装在您的服务器上。
如果该模块在这里考虑到这里,已经安装在服务器上,然后尝试升级它。因为您可能在本地机器上使用升级版本的模块,而在服务器中安装的是旧版本。


I have a simple application that allows you to upload images onto the server, and it is set up on my production server which consist of django + uwsgi + ngnix .

I have a problem when trying to upload an image. I get the following error:

error

502 Bad Gateway
nginx/1.2.1

function:

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))

template

 <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"

解决方案

if third party app included in your project then it should be installed on your server also like south is third party app. Consider south is included in your settings.py file then south should be installed on your server also. If that module consider south here, is already installed on server then try to upgrade it. Because it is possible that you are using upgraded version of module on local machine and older version is installed in the server.

这篇关于502 Bad Gateway Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆