惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
爱范儿
爱范儿
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
J
Java Code Geeks
宝玉的分享
宝玉的分享
Jina AI
Jina AI
B
Blog
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
腾讯CDC
C
Check Point Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
罗磊的独立博客
B
Blog RSS Feed
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 叶小钗
M
MIT News - Artificial intelligence
GbyAI
GbyAI

OhYee 博客

小鹏辅助驾驶测评|OhYee 博客 小鹏非支持手机开启自动解锁|OhYee 博客 使用函数计算实现 301 重定向|OhYee 博客 针对 HTML 内容使用 Ant Design 图片弹框|OhYee 博客 博客进程泄露及僵尸进程解决|OhYee 博客 蓝易云服务器体验|OhYee 博客 SSH 调起本地 VSCode|OhYee 博客 【2022 秋招内推】阿里云后端研发工程师|OhYee 博客 使用函数计算获取 IP 地址信息|OhYee 博客 正确获取客户端 IP/HTTP Header 也可能重复|OhYee 博客 评测 Oculus Quest2 及 BigScreen|OhYee 博客 NextJS 热重载保留状态|OhYee 博客 如何优雅地贴 gist 代码|OhYee 博客 Linux 精细化文件权限|OhYee 博客 VSCode 容器开发环境|OhYee 博客 Clash 的不兼容更新排查|OhYee 博客 Zeek 导出 PCAP|OhYee 博客 记一次 ssh 配置问题|OhYee 博客 Git Commit 规范化工具|OhYee 博客 谈谈《星之卡比-探索发现》|OhYee 博客 VSCode 快捷键绑定 Shell 命令|OhYee 博客 ASN.1 语法及 X.509 证书格式解析解析|OhYee 博客 腾讯企业邮箱忽略 MX 记录发信|OhYee 博客 Chrome/Edge 标签组插件|OhYee 博客 【应届内推】阿里云后端研发工程师|OhYee 博客 损坏的 Typecho 备份处理为 JSON|OhYee 博客 VS Code VIM 插件高效使用|OhYee 博客 SSH 正反向代理|OhYee 博客 Let's Encrypt 根证书过期引发的问题|OhYee 博客 OpenWRT 忽略内核依赖|OhYee 博客
V2Ray + TLS + WS(WSS) Docker 部署|OhYee 博客
2021-11-22 · via OhYee 博客

这是一篇最后编辑于 5 年前 的文章,其内容可能与目前实际情况差异较大,请注意甄别

V2Ray + TLS + WS(WSS) Docker 部署

思路: 部署一个看上去正常的网站(支持 http/https),在 https 的 /ws 端口转发到 V2Ray,使用 wss 通信

服务器

启动脚本:

#!/bin/bash

docker run --rm -d \
    --name v2ray \
    -p 127.0.0.1:22000:22000 \
    -v $HOME/v2ray/config.json:/etc/v2ray/config.json \
    v2fly/v2fly-core

服务端配置:

{
    "log": {
        "access": "",
        "error": "",
        "loglevel": "info"
    },
    "inbounds": [
        {
            "port": 22000,
            "protocol": "vless",
            "settings": {
                "udp": false,
                "clients": [
                    {
                        "id": "xxx",
                        "alterId": 0,
                        "email": "t@t.tt",
                        "flow": ""
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/ws",
                    "headers": {
                        "Host": "locvps.oyohyee.com"
                    }
                }
            }
        },
        {
            "port": 22000,
            "protocol": "vmess",
            "settings": {
                "udp": false,
                "clients": [
                    {
                        "id": "xxx",
                        "alterId": 0,
                        "email": "t@t.tt"
                    }
                ],
                "allowTransparent": false
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/ws",
                    "headers": {
                        "Host": "locvps.oyohyee.com"
                    }
                }
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom",
            "settings": {}
        },
        {
            "protocol": "blackhole",
            "settings": {},
            "tag": "blocked"
        }
    ],
    "routing": {
        "rules": [
            {
                "type": "field",
                "ip": [
                    "geoip:private"
                ],
                "outboundTag": "blocked"
            }
        ]
    }
}

Nginx 配置:

map $http_upgrade $connection_upgrade{
    default upgrade;
    '' close;
}

server {
    listen       80;
    server_name     locvps.oyohyee.com;

    location ^~ / {
        if ($host != 'www.ohyee.cc') {
            rewrite ^/(.*)$ http://www.ohyee.cc/$1 permanent;
        }
    }
}



server {
    listen       443 ssl http2;
    server_name     locvps.oyohyee.com;

    ssl_certificate     "ssl/_.oyohyee.com.crt";
    ssl_certificate_key "ssl/_.oyohyee.com.key";

    location ^~ / {
        if ($host != 'www.ohyee.cc') {
                rewrite ^/(.*)$ https://www.ohyee.cc/$1 permanent;
        }
    }

    location /ws {
        proxy_redirect off;
        proxy_pass http://127.0.0.1:22000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

客户端配置

客户端配置客户端配置

参考资料