证书过期了,就顺手升级一下 caddy2.

caddy 升级后直接使用官方 image, 增加了个小脚本自动拉取配置,真香~

感谢秋大 blog 和毕世平 blog

docker 安装以及基本操作可以参考上面两位大神

and 同时默认你搞得定 vps 以及域名等基本操作, 毕竟一搜一大把的教程

搭建

域名解析到 ip

写配置文件

  1. 创建路径 mkdir /etc/v2ray,mkdir /etc/caddy 用以存放配置文件

  2. 写入 v2ray 配置文件,

    vim /etc/v2ray/config.json

    {
          "inbounds":[
            {
              "port":10000,
              "listen":"127.0.0.1",
              "protocol":"vmess",
              "settings":{
                "clients":[
                  {
                    "id":"uuid",
                    "alterId":64
                  }
                ]
              },
              "streamSettings":{
                "network":"ws",
                "wsSettings":{
                "path":"/ray"
                }
              }
            }
          ],
          "outbounds":[
            {
              "protocol":"freedom",
              "settings":{}
            }
          ]
        }
    
  3. 写入 Caddyfile

    vim /etc/caddy/Caddyfile

    domain.me {
      encode gzip
      reverse_proxy / https://baidu.com
      reverse_proxy /ray 127.0.0.1:10000 {
        header_up -Origin
      }
    }
    

    修改 domain.me为你自己的域名

    caddy2 和 caddy1 不兼容

run 就完了

docker run -d --name caddy --restart always --net host -v /etc/caddy:/etc/caddy caddy

docker run -d --name v2ray --restart always --net host -v /etc/v2ray:/etc/v2ray teddysun/v2ray

client

客户端相关配置

修改 your.domain.com 域名即可

具体使用方法可参考相关软件文档

clashx

{"name":"bwg","type":"vmess","server":"your.domain.com","port":443,"cipher":"auto","udp":false,"uuid":"888d163a-80d7-4495-b3d1-fcf61fc6b6ce","alterId":64,"network":"ws","ws-path":"/ray","ws-headers":{"Host":"bwg.afreto.top"},"tls":true}

v2rayU

{
  "log": {
    "error": "",
    "loglevel": "error",
    "access": ""
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "protocol": "socks",
      "settings": {
        "udp": false,
        "auth": "noauth"
      },
      "port": "1086"
    },
    {
      "listen": "127.0.0.1",
      "protocol": "http",
      "settings": {
        "timeout": 360
      },
      "port": "1087"
    }
  ],
  "outbounds": [
    {
      "mux": {
        "enabled": false,
        "concurrency": 8
      },
      "protocol": "vmess",
      "streamSettings": {
        "wsSettings": {
          "path": "/ray",
          "headers": {
            "host": "bwg.afreto.top"
          }
        },
        "tlsSettings": {
          "allowInsecure": true
        },
        "security": "tls",
        "network": "ws"
      },
      "tag": "proxy",
      "settings": {
        "vnext": [
          {
            "address": "bwg.afreto.top",
            "users": [
              {
                "id": "888d163a-80d7-4495-b3d1-fcf61fc6b6ce",
                "alterId": 64,
                "level": 0,
                "security": "auto"
              }
            ],
            "port": 443
          }
        ]
      }
    }
  ],
  "dns": {},
  "routing": {
    "settings": {
      "domainStrategy": "AsIs",
      "rules": []
    }
  },
  "transport": {}
}

还是觉得好麻烦啊(一键搞定)

wget https://raw.githubusercontent.com/afret0/v2ray/master/onekey_v2ray.sh && chmod +x onekey_v2ray.sh && ./onekey_v2ray.sh

项目地址

server config

v2ray

{
      "inbounds":[
        {
          "port":10000,
          "listen":"127.0.0.1",
          "protocol":"vmess",
          "settings":{
            "clients":[
              {
                "id":"uuid",
                "alterId":64
              }
            ]
          },
          "streamSettings":{
            "network":"ws",
            "wsSettings":{
            "path":"/ray"
            }
          }
        }
      ],
      "outbounds":[
        {
          "protocol":"freedom",
          "settings":{}
        }
      ]
    }

Caddyfile

使用 caddy2 版本, 自动安装维护证书是真的香...

domain.me {
  encode gzip
  reverse_proxy / https://baidu.com
  reverse_proxy /ray 127.0.0.1:10000 {
    header_up -Origin
  }
}

附 caddy1 版本(不兼容)

mydomain.me:80 {
  redir https://mydomain.me{url}
}

mydomain.me:443 {
  gzip
  tls /root/caddy/caddy.crt /root/caddy/caddy.key
  log /root/caddy/caddy.log
  proxy / https://baidu.com
  proxy /ray 127.0.0.1:10000 {
    websocket
    header_upstream -Origin
  }
}