v2ray(WebSocket)+Nginx+CDN(CloudFlare)

2018年5月13日 科学上网 0条评论 阅读次数 8,550

基本需求

系统

Nginx安装

v2ray安装

curl https://install.direct/go.sh | bash

域名申请

Let’s Encrypt证书申请

申请CloudFlare

做一步,验证一步

tcp下v2ray

WebSocket下v2ray

"inbound": {
    "port": v2ray_listen_port,
    "protocol": "vmess",
    "settings": {
      "auth": null,
      "udp": false,
      "ip": null,
      "clients": [
        {
          "id": UUID,
          "alterId": 64,
          "security": null
        }
      ]
    },
    "streamSettings": {
      "network": "ws",
      "wsSettings": {
        "connectionReuse": true,
        "path": "/path"
      }
    }
 },

Nginx转发下v2ray

CDN转发下v2ray

# cloudflare Crypto Flexible Mode
server {
        listen           80 default_server;
        root             /usr/share/nginx/html;
        server_name      domain.com;
        location /path {
            proxy_pass            http://127.0.0.1:v2ray_listen_port;
            proxy_connect_timeout 600;
            proxy_read_timeout    600;
            proxy_http_version    1.1;
            proxy_set_header      Upgrade     $http_upgrade;
            proxy_set_header      Connection  "upgrade";
        }
    }
# cloudflare Crypto Full Mode
server {
    listen               443 ssl http2 default_server;
    root                 /usr/share/nginx/html;
    server_name          domain.com;
    ssl_certificate      /domain.cer; #可以使用openssl自签
    ssl_certificate_key  /domain.key; #可以使用openssl自签
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout   10m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    location /path {
         proxy_pass            http://127.0.0.1:v2ray_listen_port;
         proxy_connect_timeout 600;
         proxy_read_timeout    600;
         proxy_http_version    1.1;
         proxy_set_header      Upgrade     $http_upgrade;
         proxy_set_header      Connection  "upgrade";
     }
}