Curl:接收失败:对等方重置连接和 Unix 套接字崩溃

Curl:接收失败:对等方重置连接和 Unix 套接字崩溃

我正在尝试为 gunicorn 设置一个 unix 套接字并从 curl (正在运行curl --unix-socket /run/gunicorn.sock http://www.example.com --trace-ascii dump.txt) 对其进行 ping 操作。不幸的是,每次 Curl 的响应都是curl: (56) Recv failure: Connection reset by peer

查看转储日志,其中显示:

# cat dump.txt 
== Info: About to connect() to www.example.com port 80 (#0)
== Info:   Trying /run/gunicorn.sock...
== Info: Failed to set TCP_KEEPIDLE on fd 4
== Info: Failed to set TCP_KEEPINTVL on fd 4
== Info: Connected to www.example.com (/run/gunicorn.sock) port 80 (#0)
=> Send header, 79 bytes (0x4f)
0000: GET / HTTP/1.1
0010: User-Agent: curl/7.29.0
0029: Host: www.example.com
0040: Accept: */*
004d: 
== Info: Recv failure: Connection reset by peer
== Info: Closing connection 0

我发现在 fd(文件描述符?)4 上设置 TCP_KEEPIDLE 和 TCP_KEEPINTVL 会出现问题,但不确定如何修复它。

我的gunicorn.sock文件如下所示:

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

编辑:我正在尝试遵循该指南:https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04

相关内容