使用unix sock之后使用nginx代理之后会出现错误

sparks

问题描述

使用unix sock之后,webman出现错误,请看一下是什么原因

程序代码

upstream edm {
    server unix:/var/run/edm.sock;
}
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;
    server_name _;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        if (!-f $request_filename){
            proxy_pass http://edm;
        }
    }
}

报错信息

2023-12-14 19:37:24 pid:17279 worker[webman:17291] exit with status 64000
2023-12-14 19:37:24 pid:17295 Error: Call to a member function header() on string in /home/sparks/edm/vendor/workerman/webman-framework/src/App.php:638
Stack trace:
#0 /home/sparks/edm/vendor/workerman/webman-framework/src/App.php(170): Webman\App::send()
#1 /home/sparks/edm/vendor/workerman/workerman/Connection/TcpConnection.php(667): Webman\App->onMessage()
#2 [internal function]: Workerman\Connection\TcpConnection->baseRead()
#3 /home/sparks/edm/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()
#4 /home/sparks/edm/vendor/workerman/workerman/Worker.php(1635): Workerman\Events\Event->loop()
#5 /home/sparks/edm/vendor/workerman/workerman/Worker.php(1426): Workerman\Worker::forkOneWorkerForLinux()
#6 /home/sparks/edm/vendor/workerman/workerman/Worker.php(1400): Workerman\Worker::forkWorkersForLinux()
#7 /home/sparks/edm/vendor/workerman/workerman/Worker.php(1785): Workerman\Worker::forkWorkers()
#8 /home/sparks/edm/vendor/workerman/workerman/Worker.php(1721): Workerman\Worker::monitorWorkersForLinux()
#9 /home/sparks/edm/vendor/workerman/workerman/Worker.php(562): Workerman\Worker::monitorWorkers()
#10 /home/sparks/edm/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#11 /home/sparks/edm/start.php(4): support\App::run()
#12 {main}

操作系统及workerman/webman等框架组件具体版本

php8.1 wsl2 ubuntu22 nginx打开是502 bad gateway.

520 3 1
3个回答

sparks

使用端口的形式是可以的,没有问题

  • 暂无评论
nitron

edm = unix:/var/run/edm.sock;
proxypass http://edm =  proxypass http://unix:/var/run/edm.sock;

?

https://www.workerman.net/q/9540
你以前不是问过类似问题么?

  • sparks 2023-12-18

    确实有问过,不过那时候是测试,没有部署到服务器,现在部署到服务器,出现问题,不知道问题在哪里,不知道你有没有部署成功,我按你的方式,也没有部署成功

  • sparks 2023-12-18

    刚我重新试了一下,可以了,谢谢你的回复

sparks

已经可以了,是我自己的问题,少设置了一个protocol,设置完就可以了,https://www.workerman.net/q/9540

  • kspade 2023-12-19

    这是一种什么玩法

  • sparks 2023-12-19

    就是一台服务器上部署几个东西,用sock比端口方便一点,似乎性能要高一点,没测,

  • kspade 2023-12-19

    还有这种操作吗。我每次都去设定不同端口 好麻烦好多端口,队列那些名称也不能一样都会被串行消费。,

×
🔝