V2ray websocket+tls 用caddy转发端口到443

in #v2ray8 years ago

v2ray服务端文件

(html comment removed: more)
服务器端不需要配置TLS,只需要把HTTPS解密工作交给caddy,也就是配置caddy使用SSL证书,服务器端v2ray只需要接受明文WebSocket连接即可.

{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",  
    "loglevel": "warning"                  
  },
  "inbound": {
    "port": 1110,
    "protocol": "vmess",    
    "settings": {
     "clients": [
      {
      "id": "你的uid",
      "level": 1,
      "alterId": 64,
      "email": "[email protected]"
      }
     ]
    },
    "streamSettings": {
      "network": "ws",
      "wsSettings": {
        "connectionReuse": false,
        "path": "/ws"
      }
    }    
  },
  "outbound": {
    "protocol": "freedom",  
    "settings": {}
  },
  "inboundDetour": [
    {
      "protocol": "shadowsocks",
      "port": 1112,
      "settings": {
        "method": "chacha20",
        "password": "1234567",     
        "udp": false
      }
    },
    {
      "protocol": "shadowsocks",
      "port": 1113,
      "settings": {
        "method": "chacha20",
        "password": "1234567",     
        "udp": false
      }
    }
  ],
  "outboundDetour": [
    {
      "protocol": "blackhole",  
      "settings": {},
      "tag": "blocked"
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",  
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "blocked"
        }
      ]
    }
  }
}

v2ray客户端文件

{
  "inbound": {
    "port": 1080,
    "listen": "0.0.0.0",
    "protocol": "socks",
    "settings": {
      "auth": "noauth",
      "udp": true,
      "ip": "127.0.0.1",
      "clients": null
    },
    "streamSettings": null
  },
  "outbound": {
    "tag": "wsout",
    "protocol": "vmess",
    "settings": {
      "vnext": [
        {
          "address": "你的网站域名",
          "port": 443,
          "users": [
            {
              "id": "你的uid",
              "alterId": 64,
              "security": "aes-128-gcm"
            }
          ]
        }
      ]
    },
    "streamSettings": {
      "network": "ws",
      "security": "tls",
      "tlsSettings": {
        "serverName": "你的网站域名",
        "allowInsecure": true
    },
      "wsSettings": {
        "connectionReuse": true,
        "path": "/ws"
      }
    },
    "mux": {
      "enabled": true
    }
  },
  "outboundDetour": [
    {
      "protocol": "freedom",
      "settings": {
        "response": null
      },
      "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockout"
    }
  ],
  "dns": {
    "servers": [
      "8.8.8.8",
      "8.8.4.4",
      "localhost"
    ]
  },
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPIfNonMatch",
      "rules": [
        {
          "type": "field",
          "port": null,
          "outboundTag": "direct",
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "domain": null
        }
      ]
    }
  }
}

caddy配置文件:/usr/local/caddy/Caddyfile

假设你的域名是xxxx.com,证书.crt和.key放在:/etc/v2ray/

http://xxxx.com {
 redir https://xxxx.com {url}
}
https://xxxx.com {
 root /var/www/index
 gzip
index index.html
tls /etc/v2ray/v2ray.crt /etc/v2ray/v2ray.key
proxy /ws localhost:1110 {
 websocket
  }
}
Sort:  

Congratulations @wuming! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @wuming! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Support SteemitBoard's project! Vote for its witness and get one more award!

试试一下转发,谢谢分享

Congratulations @wuming! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!