【教程】NaiveProxy 安装教程,可自定义端口,拯救被墙VPS!

【教程】NaiveProxy 安装教程,可自定义端口,拯救被墙VPS!

Do Do
2022-11-11 / 0 评论 / 1,886 阅读 / 正在检测是否收录...

安装 Go

wget https://golang.google.cn/dl/go1.19.3.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.3.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> $HOME/.profile
echo 'export PATH="$PATH:~/go/bin"' >> $HOME/.profile
source $HOME/.profile

编译Caddy及Naive

go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive

配置Caddy

nano Caddyfile

贴入以下配置文件

:443, xxx.xxx.com #你的域名
tls example@example.com #你的邮箱
route {
 forward_proxy {
   basic_auth user pass #用户名和密码
   hide_ip
   hide_via
   probe_resistance
  }
 reverse_proxy  https://demo.cloudreve.org  { #伪装网址
   header_up  Host  {upstream_hostport}
   header_up  X-Forwarded-Host  {host}
  }
}

启动Caddy

./caddy start

用443端口的Naive到此就结束了

下面是用自定义端口的Naive

安装 Go和编译Caddy(带Naive插件)步骤一样

申请证书

用X-ui里的功能16一键申请,记住证书路径

bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)

config.json

nano config.json

贴入以下配置文件

//需删除注释内容caddy才能加载
{
 "apps": {
   "http": {
     "servers": {
       "srv0": {
         "listen": [
           ":33443"   //监听端口
         ],
         "routes": [
           {
             "handle": [
               {
                 "auth_user_deprecated": "user",   //用户名
                 "auth_pass_deprecated": "pass",  //密码
                 "handler": "forward_proxy",
                 "hide_ip": true,
                 "hide_via": true,
                 "probe_resistance": {}
               }
             ]
           },
           {
             "handle": [
               {
                 "handler": "reverse_proxy",
                 "headers": {
                   "request": {
                     "set": {
                       "Host": [
                         "{http.reverse_proxy.upstream.hostport}"
                       ],
                       "X-Forwarded-Host": [
                         "{http.request.host}"
                       ]
                     }
                   }
                 },
                 "transport": {
                   "protocol": "http",
                   "tls": {}
                 },
                 "upstreams": [
                   {
                     "dial": "demo.cloudreve.org:443"  //伪装网址
                   }
                 ]
               }
             ]
           }
         ],
         "tls_connection_policies": [
           {
             "match": {
               "sni": [
                 "xxx.xxx.com"  //域名
               ]
             },
             "certificate_selection": {
               "any_tag": [
                 "cert0"
               ]
             }
           }
         ],
         "automatic_https": {
           "disable": true
         }
       }
     }
   },
   "tls": {
     "certificates": {
       "load_files": [
         {
           "certificate": "/root/cert/xxx.cer",  //公钥路径
           "key": "/root/cert/xxx.key",   //私钥路径
           "tags": [
             "cert0"
           ]
         }
       ]
     }
   }
 }
}

启动

./caddy start --config config.json

最后提供一个一键脚本

项目地址
https://github.com/imajeason/nas_tools/tree/main/NaiveProxy

# 安装 naive命令
curl   https://raw.githubusercontent.com/imajeason/nas_tools/main/NaiveProxy/do.sh | bash
# 执行naive
naive
0

评论 (0)

取消