Categories
Linux

v2ray + WebSocket + TLS + Apache 配置

1.使用 LAMP 一键安装包配置 Apache 环境:https://lamp.sh/

2.运行 lamp add 时选择 Let's Encrypt 证书,后续需要使用

3.修改 /usr/local/apache/conf/httpd.conf,开启

LoadModule proxy_wstunnel_module libexec/apache2/mod_proxy_wstunnel.so

4.自行安装 v2ray,v2ray 配置如下:

{
  "inbounds": [
    {
      "port": 1090,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "Your ID",
            "alterId": 64
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/typesomething/" 
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

5.Apache 配置,修改 /usr/local/apache/conf/vhost/ 里面你运行 lamp add 新增的 vhost,在 里面添加:

<VirtualHost *:443>
       <LocationMatch "/ray/">
        ProxyPass ws://127.0.0.1:1090/typesomething/ upgrade=WebSocket
        ProxyAddHeaders Off
        ProxyPreserveHost On
        RequestHeader set Host %{HTTP_HOST}s
        RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
       </LocationMatch>
</VirtualHost>

6.客户端配置:

{
  "inbounds": [
    {
      "port": 1090,
      "listen": "127.0.0.1",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "Your Domain",
            "port": 443,
            "users": [
              {
                "id": "Your ID",
                "alterId": 64
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "wsSettings": {
          "path": "/typesomething/"
        }
      }
    }
  ]
}

7.如果你想隐藏真实 IP,可以开启使用 Cloudflare 的免费 CDN。

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code