[记录]nginx中使用shell.sock

本文详细介绍了在使用shell.sock过程中遇到的常见问题及其解决方案,包括如何解决文件找不到、resty.shell模块加载失败以及服务器重启后连接失败的问题。通过调整shell.sock的存放位置、正确加载resty.shell模块以及设置开机启动脚本来确保连接稳定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考文档:https://www.cnblogs.com/tinywan/p/6809879.html
https://github.com/juce/sockproc
https://blog.youkuaiyun.com/weixin_38652136/article/details/85775789

1.shell.sock找不到的解决办法

按照参考文档中的来做的话,shell.sock被放到了/tmp目录下,但是使用过程中,一直报文件找不到。
解决办法是将shell.sock放到其他目录。

connect() to unix:/tmp/shell.sock failed (2: No such file or directory)

例如:

./sockproc /data/shell.sock
chmod 0666 /data/shell.sock

在lua中使用的时候更换下地址即可。

在这里插入图片描述
在这里插入图片描述

2.resty.shell模块不存在

require "resty.shell"加载resty.shell模块的时候失败。参考的链接中,他resty.shell文件的拷贝看不懂,然后我是放到了跟我的nginx.conf的相对目录下的。
在这里插入图片描述
/resty/shell.lua 放到了这里。
也可以直接在nginx.conf里面的server标签前面直接装载模块。

lua_package_path "resty.shell的绝对路径"
server {...}

3.服务器重启后shell.sock无法连接

在这里插入图片描述
服务器重启后,就会报错

connect() to unix:/data/shell/shell.sock failed (111: Connection refused)

所以需要重新执行

./sockproc /data/shell.sock
chmod 0666 /data/shell.sock

命令。
我们可以把这两个命令放到开机启动时自动执行的脚本中。参考连接https://blog.youkuaiyun.com/weixin_38652136/article/details/85775789
vim /etc/rc.d/rc.local内容如下:

touch /var/lock/subsys/local
sudo /usr/local/k8s/lua/sockproc/sockproc /data/shell/shell.sock
sudo chmod 0666 /data/shell/shell.sock
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值