install

apt install v2ray

prepare

准备公私钥对,申请证书,例如letsencrypt。

server

env

假设server端:

  • host: xxx.example.com
  • port: 443
  • 私钥:/home/someusr/.cert/privkey.pem
  • 证书链: /home/someusr/.cert/fullchain.pem
  • uuid: 66666666-6666-6666-6666-666666666666

conf

配置/usr/local/etc/v2ray/config.json:

{
    "log": {
        "loglevel": "info"
    },
    "inbounds": [
        {
            "port": 443, 
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "66666666-6666-6666-6666-666666666666", 
            "flow": "xtls-rprx-origin", 
                        "level": 0
                    }
                ],
                "decryption": "none",
                "fallbacks": [
                    {
                        "dest": 80 
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "xtls",
                "xtlsSettings": {
                    "alpn": [
                        "http/1.2"
                    ],
                    "certificates": [
                        {
                            "certificateFile": "/home/someusr/.cert/fullchain.pem", 
                            "keyFile": "/home/someusr/.cert/privkey.pem" 
                        }
                    ]
                }
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom"
        }
    ]
}

run

启动

 systemctl start v2ray  

添加开机启动

 systemctl enable v2ray

client

env

假设client端:

  • 路径:/home/someclient/share/v2ray
  • local port: 8888

conf

配置/home/someclient/share/v2ray/config.json:

{
  "log": {
    "access": "",
    "error": "",
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "port": 8888,
      "listen": "127.0.0.1",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "settings": {
        "auth": "noauth",
        "udp": true,
        "ip": null,
        "clients": null
      },
      "streamSettings": null
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "xxx.example.com",
            "port": 443,
            "users": [
              {
                  "id": "66666666-6666-6666-6666-666666666666",
                  "flow": "xtls-rprx-origin",
                  "level": 0, 
            "encryption": "none"
              }
            ]
          }
        ],
        "servers": null,
        "response": null
      },
      "streamSettings": {
        "network": "tcp",
        "security": "",
        "tlsSettings": null,
        "tcpSettings": null,
        "kcpSettings": null,
        "wsSettings": null,
        "httpSettings": null,
        "quicSettings": null
      },
      "mux": {
        "enabled": true
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {
        "vnext": null,
        "servers": null,
        "response": null
      },
      "streamSettings": null,
      "mux": null
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {
        "vnext": null,
        "servers": null,
        "response": {
          "type": "http"
        }
      },
      "streamSettings": null,
      "mux": null
    }
  ],
  "dns": null,
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": []
  }
}

run

启动

cd /home/someclient/share/v2ray
v2ray run


Published

10 January 2024

Tags


Share On