map $http_upgrade $connection_upgrade{
default upgrade;
'' close;
}
upstream workman_jx{
server 127.0.0.1:50000;
}
server{
listen 80;
server_name ws.iwwee.com;
location / {
proxy_pass http://workman_jx;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# error.log
2020/06/17 11:00:25 [error] 26657#0: *2122075 upstream timed out (110: Connection timed out) while reading upstream, client: 120.239.110.113, server: ws.iwwee.com, request: "GET / HTTP/1.0", upstream: "http://127.0.0.1:50000/", host: "ws.iwwee.com"
但是直接访问不经过nginx,直接访问ws.iwwee.com:50000
又可以使用。
workman的log也没报错
workman的status如下:
Workerman[jx_50000] status
----------------------------------------------GLOBAL STATUS----------------------------------------------------
Workerman version:4.0.5 PHP version:7.1.31
start time:2020-05-28 11:54:26 run 19 days 15 hours
load average: 0.1, 0, 0 event-loop:\Workerman\Events\Select
1 workers 4 processes
worker_name exit_status exit_count
none 0 4
----------------------------------------------PROCESS STATUS---------------------------------------------------
pid memory listening worker_name connections send_fail timers total_request qps status
16549 2M websocket://0.0.0.0:50000 none 0 0 0 0 0 [idle]
16551 2M websocket://0.0.0.0:50000 none 0 0 0 0 0 [idle]
16553 2M websocket://0.0.0.0:50000 none 0 0 0 1 0 [idle]
16555 2M websocket://0.0.0.0:50000 none 0 0 0 3 0 [idle]
----------------------------------------------PROCESS STATUS---------------------------------------------------
Summary 8M - - 0 0 0 4 0 [Summary]
nginx version: nginx/1.12.2
workman代码如下:
<?php
use Workerman\Worker;
require_once __DIR__ . '/core/vendor/autoload.php';
$db_config = require_once __DIR__ . '/config/jx_db.php';
$ws_worker = new Worker("websocket://0.0.0.0:50000");
// 启动4个进程对外提供服务
$ws_worker->count = 4;
nginx version: nginx/1.12.2
经过测试,workman能收到请求,但是无法返回到nginx。
环境:套路云
端口:50000
出入规则已经开放
我用的类似这样的配置,没有问题
刚刚换成您这个配置了,但是还是不行。在服务器使用curl已经跑通了,但是在我的客户端请求服务器还是不行。
但是直接访问http协议,反代成功。但是使用ws协议,就没有返回。
好像解决了,是proxy_buffering的问题。