Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

非nobody、非root用户启动xray-core,服务端入站监听uds问题 #70

Open
maoxikun opened this issue Jan 14, 2024 · 2 comments

Comments

@maoxikun
Copy link

maoxikun commented Jan 14, 2024

问题:一旦登录服务端ssh再退出之后,uds文件会被自动删除,restart xray service之后正常,再次退出ssh之后uds文件又没了,一直循环。
1、xray-core版本: 1.8.9
2、使用如下命令安装xray-core
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u myuser
3、vless-ws-tls方式,服务端入站改为"listen": "/dev/shm/xxx.socket",nginx做相应修改
4、操作步骤:

  • 配置好服务端启动xray,有/dev/shm/domain.socket文件(不退出ssh)
  • 客户端连接(正常)
  • 服务端退出ssh
  • 客户端连接(异常)
  • 重新连接服务端ssh,发现没有/dev/shm/domain.socket文件,restart xray service之后有/dev/shm/domain.socket了,连接也正常,退出ssh之后/dev/shm/domain.socket文件又没了,周而复始

5、nginx配置

server {
    listen 50000 ssl http2;
    listen [::]: 50000 ssl http2;
    server_name xxx.com;

    ssl_certificate /home/ubuntu/tmp/cert/xxx.com_fullchain.pem;
    ssl_certificate_key /home/ubuntu/tmp/cert/xxx.com.key;
    ssl_protocols TLSv1.2 TLSv1.3;

    location /xxx {
        if ($http_upgrade != "websocket") {
            return 404;
        }
        proxy_pass http://unix:/dev/shm/xxx.socket;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }
}

6、服务端配置:

{
    "inbounds": [
        {
            "tag": "inbound-vless-ws",
            "protocol": "vless",
            "listen": "/dev/shm/xxx.socket,0666",
            "settings": {
                "clients": [
                    {
                        "id": "xxx"
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/xxx"
                },
                "security": "none"
            }
        }
    ]
}

7、客户端配置:

{
    "inbounds": [
        {
            "tag": "inbound-socks",
            "protocol": "socks",
            "listen": "127.0.0.1",
            "port": 1080,
            "settings": {
                "udp": true
            }
        }
    ],
    "outbounds": [
        {
            "tag": "proxy",
            "protocol": "vless",
            "settings": {
                "vnext": [
                    {
                        "address": "xxx",
                        "port": 50000,
                        "users": [
                            {
                                "id": "xxx",
                                "encryption": "none"
                            }
                        ]
                    }
                ]
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/xxx"
                },
                "security": "tls"
            }
        }
    ]
}
@maoxikun maoxikun changed the title Xray-install安装非nobody,非root用户启动xray-core,服务端入站监听uds问题 Xray-install安装,非nobody,非root用户启动xray-core,服务端入站监听uds问题 Jan 14, 2024
@maoxikun maoxikun changed the title Xray-install安装,非nobody,非root用户启动xray-core,服务端入站监听uds问题 Xray-install安装,非nobody、非root用户启动xray-core,服务端入站监听uds问题 Jan 14, 2024
@maoxikun maoxikun changed the title Xray-install安装,非nobody、非root用户启动xray-core,服务端入站监听uds问题 非nobody、非root用户启动xray-core,服务端入站监听uds问题 Jan 14, 2024
@maoxikun
Copy link
Author

maoxikun commented Mar 15, 2024

最后发现/dev/shm/domain.socket文件的属组是myuser,而config.json配置文件属组是root,把/dev/shm/domain.socket文件的属组改成root之后解决了,但是重启之后/dev/shm/domain.socket文件的属组还是会变成myuser,有没有大佬解决一下

@maoxikun
Copy link
Author

maoxikun commented Mar 15, 2024

不用systemd启动,换成/usr/local/bin/xray run -config /usr/local/etc/xray/config.json &正常启动,退出ssh之后uds文件不会消失,客户端能正常使用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant