gpt4 book ai didi

NGINX + uWSGI 连接被对等方重置

转载 作者:行者123 更新时间:2023-12-02 20:50:35 30 4
gpt4 key购买 nike

我正在尝试使用 uWSGI 在 NGINX 上托管 Bottle 应用程序。

这是我的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

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

我正在使用 POST 请求。为此,使用 dev Http Client。当我发送请求时,它会变得无限

http://localhost/myapp

uWSGI服务器接收请求并打印

[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 错误日志中

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"

要做什么?

最佳答案

确保在应用程序中使用您的发布数据

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

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/en/latest/ThingsToKnow.html

关于NGINX + uWSGI 连接被对等方重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13063454/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com