2025 科学教程2025 科学教程
Home
总览
  • 2023年使用Docker自建shadowsocks + v2ray-plugin翻墙教程
  • 2024年使用 Docker 自建 shadowsocks-rust + v2ray-plugin 翻墙教程
  • 2024 Shadowrocket 小火箭节点搭建教程
  • Shadowsocks 部署新方式 - 利用 Frp 提高抗封锁性
  • 使用Docker运行shadowsocks客户端
  • Proxy SwitchyOmega 的替代品: ZeroOmega
  • 修改 Clash for Windows 的内核到 Mihomo
  • 常用工具
  • 服务器推荐-Vultr(支持支付宝)
  • 临时邮箱 - 机场注册好帮手
  • 临时文件分享
  • 小机场
Home
总览
  • 2023年使用Docker自建shadowsocks + v2ray-plugin翻墙教程
  • 2024年使用 Docker 自建 shadowsocks-rust + v2ray-plugin 翻墙教程
  • 2024 Shadowrocket 小火箭节点搭建教程
  • Shadowsocks 部署新方式 - 利用 Frp 提高抗封锁性
  • 使用Docker运行shadowsocks客户端
  • Proxy SwitchyOmega 的替代品: ZeroOmega
  • 修改 Clash for Windows 的内核到 Mihomo
  • 常用工具
  • 服务器推荐-Vultr(支持支付宝)
  • 临时邮箱 - 机场注册好帮手
  • 临时文件分享
  • 小机场

Shadowsocks 部署新方式 - 利用 Frp 提高抗封锁性

  • 准备
  • 说明
  • 国内、海外服务器安装 Docker
  • 国内服务器安装 Frp Server
  • 海外 VPS 安装 Frp Client + Shadowsocks
  • 客户端配置

准备

  • 海外 VPS (vultr 支持支付包 www.vultr.com)
  • 国内大宽带 VPS (阿里、腾讯都有 200M 带宽的轻量服务器)

说明

                                                         Firewall                        
                                                            |                            
                                                            |                            
                                                            |                            
                                                            |                            
                                                            |                            
                               +--------------------+       |       +-------------------+
                               |                    |       |       |                   |
                               |     china vps      |       |       |       us vps      |
                               |                    |       |       |                   |
                               |                    |       |       |                   |
                               |                    |       |       |                   |
                               |                    |       |       |     frp-client    |
+---------------+              |                    |       |       |                   |
|               |              |                    |       |       |                   |
|               |              |     frp-server     |<------+-------+                   |
|   ss-local    +------------->|                    |       |       |                   |
|               |              |                    |       |       |      ss-server    |
|               |              |                    |       |       |                   |
+---------------+              |                    |       |       |                   |
                               |                    |       |       |                   |
                               |                    |       |       |                   |
                               |                    |       |       |                   |
                               +--------------------+       |       +-------------------+
                                                            |                            
                                                            |                            
                                                            |                            
                                                            |                            
                                                            |                            
                                                            |                            
                                                            |                            
  • ss-local:本地 shadowsocks 客户端
  • frp-server:frp 服务端
  • frp-client:frp 客户端
  • ss-server:shadowsocks 服务端

原始的 shadowsocks 代理工作模式为本地客户端主动连接海外VPS上的服务端,连接过程中过墙,很容易封锁 ip 或端口。

本教程利用 FRP,将主动连接放到海外 VPS 端,海外 VPS 上的 frp-client 主动连接国内服务器 frp-server,建立隧道后承载 shadowsocks 流量。

缺点:此方法会增加国内服务器成本。

国内、海外服务器安装 Docker

  1. 海外服务器使用一件脚本安装 Docker:VPS 安装 Docker 教程

  2. 国内机器购买配置时,可以直接选择 Docker 镜像,或者按照阿里腾讯官方文档

附:

  • 阿里-安装 Docker 并使用镜像仓库
  • 阿里-轻量应用服务器快速部署 Docker
  • 腾讯-云服务器搭建 Docker 环境
  • 腾讯-安装 Docker 并配置镜像加速源

国内服务器安装 Frp Server

  1. 下载 frp 源代码
git clone https://github.com/fatedier/frp.git
cd frp
cp dockerfiles/Dockerfile-for-frps Dockerfile
  1. 修改 Dockerfile,添加国内 GOPROXY 镜像源:
FROM golang:1.23 AS building

COPY . /building
WORKDIR /building

# 设置环境变量
ENV GOPROXY=https://mirrors.tencent.com/go/

RUN make frps

FROM alpine:3

RUN apk add --no-cache tzdata

COPY --from=building /building/bin/frps /usr/bin/frps

ENTRYPOINT ["/usr/bin/frps"]

如果是阿里云,改成以下内容:

ENV GOPROXY=https://mirrors.aliyun.com/goproxy/
  1. 构建镜像
docker build -t frps ./
  1. 新建 frps.toml 配置文件
nano frps.toml
bindPort = 7000
auth.method = "token"
auth.token = "password"

修改 password 为自定义密码,后面 frp-client 配置需要相同。

  1. 新建 docker-compose 文件
nano docker-compose.yml
services:
  frps:
    image: frps
    container_name: frps
    restart: always
      - "7000:7000"        # 映射用于内网穿透的端口,根据需要添加更多端口映射
      - "7500:7500"
    volumes:
      - ./frps.toml:/frps.toml  # 挂载本地的 frps.ini 配置文件到容器中
    command: ["-c", "/frps.toml"]
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "3"
  1. 启动 frp-server
docker compose up -d
  1. 在后台防火墙放行 tcp 7000、7500 端口

海外 VPS 安装 Frp Client + Shadowsocks

  1. 下载 frp 源代码
git clone https://github.com/fatedier/frp.git
cd frp
cp dockerfiles/Dockerfile-for-frpc Dockerfile
  1. 构建镜像
docker build -t frpc ./
  1. 新建 frpc.toml 配置文件
nano frpc.toml
serverAddr = "国内服务器ip"
serverPort = 7000
auth.method = "token"
auth.token = "password"
transport.protocol = "tcp"

[[proxies]]
name = "ss"
type = "tcp"
localIP = "ssserver"
localPort = 7500
remotePort = 7500
transport.useCompression = true
  • 国内服务器 ip 修改为你所购买的国内服务器 IP
  • 修改 password 为上面在国内服务器配置的 frp-server 自定义密码
  1. 新建 shadowsocks 服务端配置文件
nano config.json
{
    "server":"0.0.0.0",
    "server_port":7500,
    "local_port":1080,
    "password":"ss password",
    "timeout":60,
    "method":"chacha20-ietf-poly1305",
    "fast_open": true,
    "mode":"tcp_only"
}

ss password 修改为自定义 shadowsocks 密码

  1. 新建 docker-compose 文件
nano docker-compose.yml
services:
  frpc:
    image: frpc
    container_name: frpc
    restart: always
    volumes:
      - ./frpc.toml:/frpc.toml  # 挂载本地的 frps.ini 配置文件到容器中
    command: ["-c", "/frpc.toml"]
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "3"

  ssserver:
    image: teddysun/shadowsocks-libev
    restart: always         # 设置该参数即可实现自启动
    volumes:
      -  ./config.json:/etc/shadowsocks-libev/config.json
    command: ss-server -c /etc/shadowsocks-libev/config.json
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "3"
  1. 启动 frp-client 和 shadowsocks 服务端
docker compose up -d

客户端配置

  • 服务器 IP:配置国内服务器 IP
  • 端口:7500
  • 加密方式:chacha20-ietf-poly1305
  • 密码:自定义 shadowsocks 密码
Last Updated:
Contributors: admin