NGINX + uWSGI对等连接重置 [英] NGINX + uWSGI Connection Reset by Peer

查看:248
本文介绍了NGINX + uWSGI对等连接重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用uWSGI在NGINX上托管Bottle Application.

I'm trying to host Bottle Application on NGINX using uWSGI.

这是我的 nginx.conf

location /myapp/ {
        include uwsgi_params;
        uwsgi_param X-Real-IP $remote_addr;
        uwsgi_param Host $http_host;
        uwsgi_param UWSGI_SCRIPT myapp;
        uwsgi_pass 127.0.0.1:8080;
    }

我正在以此方式运行uwsgi

I'm running uwsgi as this

uwsgi --enable-threads --socket :8080 --plugin python -- wsgi-file ./myApp/myapp.py

我正在使用POST请求.为此,使用dev Http Client.当我发送请求时

I'm using POST Request. For that using dev Http Client. Which goes infinite when I send the request

http://localhost/myapp

uWSGI服务器接收请求并打印

uWSGI server receives the request and prints

[pid: 4683|app: 0|req: 1/1] 127.0.0.1 () {50 vars in 806 bytes} [Thu Oct 25 12:29:36 2012] POST /myapp => generated 737 bytes in 11 msecs (HTTP/1.1 404) 2 headers in 87 bytes (1 switches on core 0)

但在nginx错误日志中

but in nginx error log

2012/10/25 12:20:16 [error] 4364#0: *11 readv() failed (104: Connection reset by peer) while reading upstream, client: 127.0.0.1, server: localhost, request: "POST /myApp/myapp/ HTTP/1.1", upstream: "uwsgi://127.0.0.1:8080", host: "localhost"

该怎么办?

推荐答案

确保在您的应用程序中使用您的帖子数据

make sure to consume your post data in your application

例如,如果您有Django/python应用程序

for example if you have a Django/python application

def my_view(request):

    # ensure to read the post data, even if you don't need it
    # without this you get a: failed (104: Connection reset by peer)
    data = request.DATA

    return HttpResponse("Hello World")

一些详细信息: https://uwsgi-docs.readthedocs.io/zh/latest/ThingsToKnow.html

这篇关于NGINX + uWSGI对等连接重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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