Skip to content

Instantly share code, notes, and snippets.

@woq
Last active July 3, 2020 06:07
Show Gist options
  • Save woq/54177d56273aa69efa7230138b5930ea to your computer and use it in GitHub Desktop.
Save woq/54177d56273aa69efa7230138b5930ea to your computer and use it in GitHub Desktop.
V2ray TLS with Websocket
{
    "inbounds": [
    {
      "port": 替换端口,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "替换ID",
            "level": 1,
            "alterId": 64
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/vray"
        }
      }
    }
  ],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}

测试命令 v2ray -test -config /etc/v2ray/config.json

  location /ray { # 与 V2Ray 配置中的 path 保持一致
    if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
        return 404;
    }
    proxy_redirect off;
    proxy_pass http://127.0.0.1:10000; # 假设WebSocket监听在环回地址的10000端口上
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    # Show real IP in v2ray access.log
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
service v2ray restart/start/status
/usr/bin/v2ray/v2ray -test -config /etc/v2ray/config.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment