分类目录归档:云乞讨

rsync 同步文件 基础的用法 使用教程 2022-04-17

需求描述

我把自己的BT下载放在云VPS上了,这样可以不占用家里宽带的上行带宽,文件在VPS上下载完成后,通过rsync命令,把文件同步到本地的树莓派即可

这里就来介绍一个rsync这个工具的基础用法

rsync,同步文件的工具,支持增量备份

环境描述

1、 云服务器VPS的Linux环境,BT下载,Nextcloud云盘

2、本地树莓派Linux环境

配置实施

需求是同步云服务器里面的文件,到本地的树莓派的SSD固态硬盘上

本地和远端都安装rsync,我这里都是Ubuntu,直接如下命令即可安装

apt-get update
apt-get install rsync

参数释义

-v:显示rsync过程中详细信息。可以使用"-vvvv"获取更详细信息。
-P:显示文件传输的进度信息。(实际上"-P"="--partial --progress",其中的"--progress"才是显示进度信息的)。
-n --dry-run  :仅测试传输,而不实际传输。常和"-vvvv"配合使用来查看rsync是如何工作的。
-a --archive  :归档模式,表示递归传输并保持文件属性。等同于"-rtopgDl"。
-r --recursive:递归到目录中去。
-t --times:保持mtime属性。强烈建议任何时候都加上"-t",否则目标文件mtime会设置为系统时间,导致下次更新
          :检查出mtime不同从而导致增量传输无效。
-o --owner:保持owner属性(属主)。
-g --group:保持group属性(属组)。
-p --perms:保持perms属性(权限,不包括特殊权限)。
-D        :是"--device --specials"选项的组合,即也拷贝设备文件和特殊文件。
-l --links:如果文件是软链接文件,则拷贝软链接本身而非软链接所指向的对象。
-z        :传输时进行压缩提高效率。
-R --relative:使用相对路径。意味着将命令行中指定的全路径而非路径最尾部的文件名发送给服务端,包括它们的属性。用法见下文示例。
--size-only :默认算法是检查文件大小和mtime不同的文件,使用此选项将只检查文件大小。
-u --update :仅在源mtime比目标已存在文件的mtime新时才拷贝。注意,该选项是接收端判断的,不会影响删除行为。
-d --dirs   :以不递归的方式拷贝目录本身。默认递归时,如果源为"dir1/file1",则不会拷贝dir1目录,使用该选项将拷贝dir1但不拷贝file1。
--max-size  :限制rsync传输的最大文件大小。可以使用单位后缀,还可以是一个小数值(例如:"--max-size=1.5m")
--min-size  :限制rsync传输的最小文件大小。这可以用于禁止传输小文件或那些垃圾文件。
--exclude   :指定排除规则来排除不需要传输的文件。
--delete    :以SRC为主,对DEST进行同步。多则删之,少则补之。注意"--delete"是在接收端执行的,所以它是在
            :exclude/include规则生效之后才执行的。
-b --backup :对目标上已存在的文件做一个备份,备份的文件名后默认使用"~"做后缀。
--backup-dir:指定备份文件的保存路径。不指定时默认和待备份文件保存在同一目录下。
-e          :指定所要使用的远程shell程序,默认为ssh。
--port      :连接daemon时使用的端口号,默认为873端口。
--password-file:daemon模式时的密码文件,可以从中读取密码实现非交互式。注意,这不是远程shell认证的密码,而是rsync模块认证的密码。
-W --whole-file:rsync将不再使用增量传输,而是全量传输。在网络带宽高于磁盘带宽时,该选项比增量传输更高效。
--existing  :要求只更新目标端已存在的文件,目标端还不存在的文件不传输。注意,使用相对路径时如果上层目录不存在也不会传输。
--ignore-existing:要求只更新目标端不存在的文件。和"--existing"结合使用有特殊功能,见下文示例。
--remove-source-files:要求删除源端已经成功传输的文件。


Options
 -v, --verbose               increase verbosity
     --info=FLAGS            fine-grained informational verbosity
     --debug=FLAGS           fine-grained debug verbosity
     --msgs2stderr           special output handling for debugging
 -q, --quiet                 suppress non-error messages
     --no-motd               suppress daemon-mode MOTD (see manpage caveat)
 -c, --checksum              skip based on checksum, not mod-time & size
 -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
     --no-OPTION             turn off an implied OPTION (e.g. --no-D)
 -r, --recursive             recurse into directories
 -R, --relative              use relative path names
     --no-implied-dirs       don't send implied dirs with --relative
 -b, --backup                make backups (see --suffix & --backup-dir)
     --backup-dir=DIR        make backups into hierarchy based in DIR
     --suffix=SUFFIX         set backup suffix (default ~ w/o --backup-dir)
 -u, --update                skip files that are newer on the receiver
     --inplace               update destination files in-place (SEE MAN PAGE)
     --append                append data onto shorter files
     --append-verify         like --append, but with old data in file checksum
 -d, --dirs                  transfer directories without recursing
 -l, --links                 copy symlinks as symlinks
 -L, --copy-links            transform symlink into referent file/dir
     --copy-unsafe-links     only "unsafe" symlinks are transformed
     --safe-links            ignore symlinks that point outside the source tree
     --munge-links           munge symlinks to make them safer (but unusable)
 -k, --copy-dirlinks         transform symlink to a dir into referent dir
 -K, --keep-dirlinks         treat symlinked dir on receiver as dir
 -H, --hard-links            preserve hard links
 -p, --perms                 preserve permissions
 -E, --executability         preserve the file's executability
     --chmod=CHMOD           affect file and/or directory permissions
 -A, --acls                  preserve ACLs (implies --perms)
 -X, --xattrs                preserve extended attributes
 -o, --owner                 preserve owner (super-user only)
 -g, --group                 preserve group
     --devices               preserve device files (super-user only)
     --copy-devices          copy device contents as regular file
     --specials              preserve special files
 -D                          same as --devices --specials
 -t, --times                 preserve modification times
 -O, --omit-dir-times        omit directories from --times
 -J, --omit-link-times       omit symlinks from --times
     --super                 receiver attempts super-user activities
     --fake-super            store/recover privileged attrs using xattrs
 -S, --sparse                turn sequences of nulls into sparse blocks
     --preallocate           allocate dest files before writing them
 -n, --dry-run               perform a trial run with no changes made
 -W, --whole-file            copy files whole (without delta-xfer algorithm)
     --checksum-choice=STR   choose the checksum algorithms
 -x, --one-file-system       don't cross filesystem boundaries
 -B, --block-size=SIZE       force a fixed checksum block-size
 -e, --rsh=COMMAND           specify the remote shell to use
     --rsync-path=PROGRAM    specify the rsync to run on the remote machine
     --existing              skip creating new files on receiver
     --ignore-existing       skip updating files that already exist on receiver
     --remove-source-files   sender removes synchronized files (non-dirs)
     --del                   an alias for --delete-during
     --delete                delete extraneous files from destination dirs
     --delete-before         receiver deletes before transfer, not during
     --delete-during         receiver deletes during the transfer
     --delete-delay          find deletions during, delete after
     --delete-after          receiver deletes after transfer, not during
     --delete-excluded       also delete excluded files from destination dirs
     --ignore-missing-args   ignore missing source args without error
     --delete-missing-args   delete missing source args from destination
     --ignore-errors         delete even if there are I/O errors
     --force                 force deletion of directories even if not empty
     --max-delete=NUM        don't delete more than NUM files
     --max-size=SIZE         don't transfer any file larger than SIZE
     --min-size=SIZE         don't transfer any file smaller than SIZE
     --partial               keep partially transferred files
     --partial-dir=DIR       put a partially transferred file into DIR
     --delay-updates         put all updated files into place at transfer's end
 -m, --prune-empty-dirs      prune empty directory chains from the file-list
     --numeric-ids           don't map uid/gid values by user/group name
     --usermap=STRING        custom username mapping
     --groupmap=STRING       custom groupname mapping
     --chown=USER:GROUP      simple username/groupname mapping
     --timeout=SECONDS       set I/O timeout in seconds
     --contimeout=SECONDS    set daemon connection timeout in seconds
 -I, --ignore-times          don't skip files that match in size and mod-time
 -M, --remote-option=OPTION  send OPTION to the remote side only
     --size-only             skip files that match in size
 -@, --modify-window=NUM     set the accuracy for mod-time comparisons
 -T, --temp-dir=DIR          create temporary files in directory DIR
 -y, --fuzzy                 find similar file for basis if no dest file
     --compare-dest=DIR      also compare destination files relative to DIR
     --copy-dest=DIR         ... and include copies of unchanged files
     --link-dest=DIR         hardlink to files in DIR when unchanged
 -z, --compress              compress file data during the transfer
     --compress-level=NUM    explicitly set compression level
     --skip-compress=LIST    skip compressing files with a suffix in LIST
 -C, --cvs-exclude           auto-ignore files the same way CVS does
 -f, --filter=RULE           add a file-filtering RULE
 -F                          same as --filter='dir-merge /.rsync-filter'
                             repeated: --filter='- .rsync-filter'
     --exclude=PATTERN       exclude files matching PATTERN
     --exclude-from=FILE     read exclude patterns from FILE
     --include=PATTERN       don't exclude files matching PATTERN
     --include-from=FILE     read include patterns from FILE
     --files-from=FILE       read list of source-file names from FILE
 -0, --from0                 all *-from/filter files are delimited by 0s
 -s, --protect-args          no space-splitting; only wildcard special-chars
     --address=ADDRESS       bind address for outgoing socket to daemon
     --port=PORT             specify double-colon alternate port number
     --sockopts=OPTIONS      specify custom TCP options
     --blocking-io           use blocking I/O for the remote shell
     --stats                 give some file-transfer stats
 -8, --8-bit-output          leave high-bit chars unescaped in output
 -h, --human-readable        output numbers in a human-readable format
     --progress              show progress during transfer
 -P                          same as --partial --progress
 -i, --itemize-changes       output a change-summary for all updates
     --out-format=FORMAT     output updates using the specified FORMAT
     --log-file=FILE         log what we're doing to the specified FILE
     --log-file-format=FMT   log updates using the specified FMT
     --password-file=FILE    read daemon-access password from FILE
     --list-only             list the files instead of copying them
     --bwlimit=RATE          limit socket I/O bandwidth
     --stop-at=y-m-dTh:m     Stop rsync at year-month-dayThour:minute
     --time-limit=MINS       Stop rsync after MINS minutes have elapsed
     --outbuf=N|L|B          set output buffering to None, Line, or Block
     --write-batch=FILE      write a batched update to FILE
     --only-write-batch=FILE like --write-batch but w/o updating destination
     --read-batch=FILE       read a batched update from FILE
     --protocol=NUM          force an older protocol version to be used
     --iconv=CONVERT_SPEC    request charset conversion of filenames
     --checksum-seed=NUM     set block/file checksum seed (advanced)
     --noatime               do not alter atime when opening source files
 -4, --ipv4                  prefer IPv4
 -6, --ipv6                  prefer IPv6
     --version               print version number
(-h) --help                  show this help (-h is --help only if used alone)


源路径如果是一个目录的话,带上尾随斜线和不带尾随斜线是不一样的,不带尾随斜线表示的是整个目录包括目录本身,带上尾随斜线表示的是目录中的文件,不包括目录本身

rsync -avz -e "ssh -p 22" root@10.11.11.247:/root/src /root/


rsync -avz -e "ssh -p 22" root@10.11.11.247:/root/src/*.gz /root/src/

基于v2ray使用其他Shadowsocks服务器的IP为落地 2022-4-12

段落1、需求描述

1台服务器,已配置的Shadowsocks-libev ,IP地址为 10.11.11.247

ss://aes-128-gcm:P1122330099@10.11.11.247:16805

1台服务器,配置的V2ray服务端,IP地址为 10.11.11.223

现在,需要让v2ray的流量,走到SS去。

实现的路由方向为:客户端 ~ ~ V2ray服务 ~ ~ SS服务

# Shadowsocks-libev IPv6出站优先的配置,参考 https://dasmz.com/?p=1804

# 编译安装Shadowsocks-libev服务端,AEAD加密算法支持,参考 https://dasmz.com/?p=1845

# 基于v2ray使用免费的socks5的IP为落地 ,参考 https://dasmz.com/?p=560

# VMess MD5 认证信息 淘汰机制 https://dasmz.com/?p=1051

段落2、需要配置V2ray的outbound参数

V2服务端配置文件

{
  "log": {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/errors.log",
    "loglevel": "info"
  },
  "inbound": {
    "port": 18505,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "5b61942a-b2ee-434b-b39b-83daa7fcda39",
          "level": 1,
          "alterId": 6
        }
      ]
    }
  },
  "outbounds": [
    {
      "protocol": "shadowsocks",
      "settings": {
        "servers": [
          {
            "address": "10.11.11.247",
            "method": "aes-128-gcm",
            "ota": false,
            "password": "P1122330099",
            "port": 16805  
          }
        ]
      }
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",
          "ip": [
            "10.0.0.0/8"
          ],
          "outboundTag": "blocked"
        }
      ]
    }
  }
}

          

上方是出站到Shadowsocks的服务端配置样例,已经过测试,有效。Shadowsocks的OTA已废弃,务必选择AEAD的加密算法。

客户端配置

{
  "log": {
    "access": "",
    "error": "",
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "tag": "proxy",
      "port": 10808,
      "listen": "127.0.0.1",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "10.11.11.223",
            "port": 18505,
            "users": [
              {
                "id": "5b61942a-b2ee-434b-b39b-83daa7fcda39",
                "alterId": 6,
                "email": "t@t.tt",
                "security": "auto"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "tcp"
      },
      "mux": {
        "enabled": false,
        "concurrency": -1
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {}
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    }
  ],
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api"
      }
    ]
  }
}
可能的报错,如果程序启动失败,大概率是v2ray对于非AEAD的加密算法的抛弃

例如
V2Ray 4.44.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.17.3 linux/amd64)
A unified platform for anti-censorship.
2022/04/12 18:14:05 [Info] main/jsonem: Reading config: /etc/v2ray/config.json
main: failed to read config files: [/etc/v2ray/config.json] > infra/conf: unknown cipher method: aes-128-cfb

附录1、参考链接的清单

参考V2的SS协议配置 https://www.v2ray.com/en/configuration/protocols/shadowsocks.html

参考v2fly的配置 https://guide.v2fly.org/basics/shadowsocks.html#%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%85%8D%E7%BD%AE

NaïveProxy 搭建部署安装教程 2022-4-8

段落1、简略介绍

NaïveProxy是一个基于谷歌浏览器的网络组建,进行数据包转发的套件,具体的用途,你们懂的呦,它最大的优势是TLS的流量指纹,是谷歌浏览器Chrome的,那个叫啥“泯然众人”,是的,流量就是特征就跟普通浏览器的一模一样了。

项目地址 https://github.com/klzgrad/naiveproxy

段落2、环境

美国服务器 1C-1G-15GB磁盘

本地Windows电脑

段落3、软件套装

Debian 10 系统

go语言环境

caddy环境,因为需要其正向代理的功能,Nginx目前不支持。

段落4、安装GO语言的环境

官网 https://go.dev/

GO Download Page

当前日期,go版本为1.18,但是,我这里需要安装go 1.17,因为go 1.18暂时还不支持qtls,如果有新版本,qtls功能支持了,你们到时候可以安装新版本。

root@server:~#  apt-get update
root@server:~#  apt-get install libnss3 debian-keyring debian-archive-keyring apt-transport-https   #安装依赖
root@server:~#  mkdir -p /root/src/ /usr/local/
root@server:~#  cd /root/src/
root@server:~#  wget https://go.dev/dl/go1.17.linux-amd64.tar.gz
root@server:~#  tar -zxvf go1.17.linux-amd64.tar.gz -C /usr/local/
root@server:~#  vi /etc/profile
#  /etc/profile 中添加 GO语言的 环境变量
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH
root@server:~#  source /etc/profile
root@server:~#  which go
/usr/local/go/bin/go
root@server:~#  go version
go version go1.17 linux/amd64

段落5、安装NaïveProxy和Caddy

需要安装NaïveProxy,且不是单独安装Caddy,务必按照命令执行。

以下命令,在服务器上执行,需要保证服务器到github的网络通畅。编译build需要一定的时间,看你服务器的CPU性能,耐心等待。

root@server:~# cd /root/src/
root@server:~# go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
root@server:~# ~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive
root@server:~# cp caddy /usr/bin/
root@server:~# /usr/bin/caddy version        # 2022-4-8 23:09
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=  
root@server:~# setcap cap_net_bind_service=+ep /usr/bin/caddy  # 设置bind权限,可443

安装日志记录

root@server:~#   go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
go: downloading github.com/caddyserver/xcaddy v0.2.1
go: downloading github.com/Masterminds/semver/v3 v3.1.1

root@server:~#   ~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive
2022/04/08 04:15:51 [INFO] Temporary folder: /tmp/buildenv_2022-04-08-0415.1787806031
2022/04/08 04:15:51 [INFO] Writing main module: /tmp/buildenv_2022-04-08-0415.1787806031/main.go
2022/04/08 04:15:51 [INFO] Initializing Go module
2022/04/08 04:15:51 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy 
go: creating new go.mod: module caddy
go: to add module requirements and sums:
	go mod tidy
2022/04/08 04:15:51 [INFO] Replace github.com/caddyserver/forwardproxy => github.com/klzgrad/forwardproxy@naive
2022/04/08 04:15:51 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod edit -replace github.com/caddyserver/forwardproxy=github.com/klzgrad/forwardproxy@naive 
2022/04/08 04:15:51 [INFO] Pinning versions
2022/04/08 04:15:51 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2 
go: downloading github.com/caddyserver/caddy/v2 v2.4.6
go: downloading github.com/caddyserver/caddy v1.0.5
...
日志非常多,不贴出来了……
...
/root/go/pkg/mod/github.com/lucas-clemente/quic-go@v0.23.0/internal/qtls/go118.go:5:13: cannot use "quic-go doesn't build on Go 1.18 yet." (untyped string constant) as int value in variable declaration

如果出现如下的报错提示,则需要降级GO语言环境

/root/go/pkg/mod/github.com/lucas-clemente/quic-go@v0.23.0/internal/qtls/go118.go:5:13: cannot use "quic-go doesn't build on Go 1.18 yet." (untyped string constant) as int value in variable declaration

报错提示,根据开发者说,暂时go 1.18还没有支持到qtls,所以,要安装go 1.17版本即可。

如果安装出现上面的报错,则把执行命令的目录下的缓存目录删掉,重新build即可。

如果提醒内容如下,表示build成功

go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
go: downloading github.com/OneOfOne/xxhash v1.2.2
go: downloading github.com/spaolacci/murmur3 v1.1.0
go: downloading github.com/fsnotify/fsnotify v1.4.9
go: downloading golang.org/x/mod v0.4.2
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: downloading github.com/klzgrad/forwardproxy v0.0.0-20210613072432-ff60d3bb5ad1
go: found github.com/caddyserver/forwardproxy in github.com/caddyserver/forwardproxy v0.0.0-00010101000000-000000000000
go: downloading github.com/klauspost/cpuid v1.2.5
2022/04/08 06:12:32 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /root/src/caddy -ldflags -w -s -trimpath 
2022/04/08 06:17:07 [INFO] Build complete: ./caddy
2022/04/08 06:17:07 [INFO] Cleaning up temporary folder: /tmp/buildenv_2022-04-08-0548.1309641503

段落6、Caddy的配置文件

通常大家都用的IPv4地址,故而,这里需要配置一个域名的A记录,指向你的服务器公网IPv4地址,且需要一套可信的证书文件,不要用自签的证书。

官方给到的配置示例

{
  servers {
    protocol {
      experimental_http3
    }
  }
}
:443, example.com
tls me@example.com
route {
  forward_proxy {
    basic_auth user pass
    hide_ip
    hide_via
    probe_resistance
  }
  file_server { root /var/www/html }
}

语法解释,官方地址 https://caddyserver.com/docs/json/

{
  servers {
    protocol {
      experimental_http3  # 启用 HTTP/3
    }
  }
}
:443, example.com   # example.com为服务器的A或者AAAA记录,域名
tls me@example.com   # 邮箱地址
route {
  forward_proxy {
    basic_auth user pass   # 自定义用户名和密码 #多用户就按照这个格式新增一行
    hide_ip
    hide_via
    probe_resistance  # 抗探测
  }
  reverse_proxy {another.website.domain} # 要反代的网站,二选一
  file_server { root /var/www/html } # 自检的网站,二选一
}

Dasmz提醒,目前来说,国内的网络环境,不推荐启用HTTP/3,因为它使用了QUIC/UDP,国内的运营商QoS,对此并不友好。

其他Caddy参数用法示例
forwardproxy {
    basicauth user1 password1
    basicauth user2 password2
    ports     80 443
    hide_ip
    hide_via
    probe_resistance secret-link-kWWL9Q.com # alternatively you can use a real domain, such as caddyserver.com
    serve_pac        /secret-proxy.pac
    response_timeout 30
    dial_timeout     30
    upstream         https://user:password@extra-upstream-hop.com
    acl {
      allow     *.caddyserver.com
      deny      192.168.1.1/32 192.168.0.0/16 *.prohibitedsite.com *.localhost
      allow     ::1/128 8.8.8.8 github.com *.github.io
      allowfile /path/to/whitelist.txt
      denyfile  /path/to/blacklist.txt
      allow     all
      deny      all # unreachable rule, remaining requests are matched by `allow all` above
    }
}
给到一个服务器的示范配置信息 2022-4-9
#  /etc/caddy/caddy_server.json
{
  "admin": {
    "disabled": true
  },
  "logging": {
    "sink": {
      "writer": {
        "output": "discard"
      }
    },
    "logs": {
      "default": {
        "writer": {
          "output": "discard"
        }
      }
    }
  },
  "apps": {
    "http": {
      "servers": {
        "srv0": {
          "listen": [
            ":18443"
          ],
          "routes": [
            {
              "handle": [
                {
                  "handler": "subroute",
                  "routes": [
                    {
                      "handle": [
                        {
                          "auth_pass_deprecated": "U",
                          "auth_user_deprecated": "P_75b8B1",
                          "handler": "forward_proxy",
                          "hide_ip": true,
                          "hide_via": true,
                          "probe_resistance": {}
                        }
                      ]
                    },
                    {
                      "match": [
                        {
                          "host": [
                            "server.my999999999.com"
                          ]
                        }
                      ],
                      "handle": [
                        {
                          "handler": "file_server",
                          "root": "/var/www/html",
                          "index_names": [
                            "index.html"
                          ]
                        }
                      ],
                      "terminal": true
                    }
                  ]
                }
              ]
            }
          ],
          "experimental_http3": false,
          "tls_connection_policies": [
            {
              "match": {
                "sni": [
                  "server.my999999999.com"
                ]
              }
            }
          ],
          "automatic_https": {
            "disable": true
          }
        }
      }
    },
    "tls": {
      "certificates": {
        "load_files": [
          {
            "certificate": "/root/server.my999999999.com/server.my999999999.com.cer",
            "key": "/root/server.my999999999.com/server.my999999999.com.key"
          }
        ]
      }
    }
  }
}

运行服务端

/usr/bin/caddy run --config /etc/caddy/caddy_server.json

段落7、配置服务

# /etc/systemd/system/naive.service
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/caddy_server.json
ExecReload=/usr/bin/caddy reload --config /etc/caddy/caddy_server.json
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

段落8、客户端配置

Release页面,下载 NaiveProxy 对应的客户端,解压执行,尽量用新版本的,修改config.json配置文件,编辑客户端配置文件,/etc/naive/config.json

{
  "listen": "socks://127.0.0.1:1080",
  "proxy": "https://U:P_75b8B1@server.my999999999.com:18443"
}
# 客户端执行
naive config.json

NaiveProxy 客户端配置(如果使用 HTTP3 则将 https:// 改为 quic://)

附录1、参考

XCADDY项目 https://github.com/caddyserver/xcaddy

https://www.oilandfish.com/posts/naiveproxy-caddy-2.html

https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh

云平台,虚拟化,Proxmox VE基础入门及进阶 2022-4-6

自己在测试一些软件,程序的时候,有时候,希望有一个轻量级别的云计算环境,虚拟化环境,可选的是EXSi,Proxmox VE,Openstack,Hyper-V,XCP-ng

国人,应该用的居多的是EXSi,相比于商业盗版,会收到律师函,个人使用盗版,目前大环境下,没有法律问题。

今天,我们给大家介绍的是Proxmox VE,下面简称 PVE

段落1、PVE入门篇,下载,安装

PVE,是一个全虚拟化的平台,需要直接在硬件设施上部署安装,它是适合一个简单的小型组网结构的虚拟化平台,符合我搭建一个简易测试环境的需求。

官网地址 https://www.proxmox.com/en/downloads

在写本篇文章的今天(2022-4-6),PVE的最新稳定版本为,7.1-2,直接从官网下载这个ISO安装包即可

使用UltraISO,Rufus,Ventoy这类U盘写镜像的工具,把这个做成一个启动盘。

进入安装引导后,给电脑接上网线,有几个选项

1、需要安装到的盘,我这里,选择的是我的120GB的SSD固态硬盘,格式为EXT4

2、主机名,要写成 xxx.domain.com

3、邮箱,可以写真实的 yourname@126.com

4、安装完成,访问地址一般是 https://192.168.1.X:8006/ 用户名root,密码是你刚刚自定义的

在自己的本机电脑上,打开浏览器,打开上面的访问地址即可通过WEB管理PVE,这样一个最基础的虚拟化PVE环境,就算搭建完成了。

默认是英文环境,打开WEB管理页面后,选择右上方的root@pam位置点击,选择languages,选择 Chinese Simplified(简体中文)

段落2、PVE入门篇,使用ubuntu 20.04的iso镜像,创建一个虚机

前缀,我这里PVE安装在笔记本电脑上,处理器i3,总内存8GB,总磁盘是120GB的SSD,网口就笔记本电脑的网线网卡,网线连接到家里的主路由器。

1、下载ubuntu20.04的镜像,一般推荐从ubuntu官网下载,大陆地址的建议从国内的镜像源下载,速度比较快。镜像源头较多,主流的如,清华源,中科大源,阿里源,腾讯源,163源等。

如图,一般服务器用途的,下载live-server版本, ubuntu-20.04.4-live-server-amd64.iso

2、上传刚下载的ubuntu 20.04的ISO镜像到PVE的 local/ISO Images

3、点击左侧宿主机的名称,点击 创建虚拟机(create vm),名称ubuntu-20.04-server1,

下一步,到操作系统菜单,选择自己想要安装的ISO镜像

系统,默认

硬盘,磁盘空间,看你们自己的需求选择,不能超过本地磁盘的可用量,一般个人用的Ubuntu服务器,15GB磁盘够用了。

CPU,个人用的Linux Server,一般1核心够用

内存,个人用途的Linux Server,一般1GB够用

网络,我这里,默认的桥接的vmbr0

下面,开机,在左侧刚刚创建的虚机名称中,点击控制台,即可看到安装ubuntu 20.04的界面。

附录

000089. 云平台,虚拟化,Proxmox VE基础入门 20220406

本期博客地址 https://dasmz.com/?p=1869
本期视频地址 https://youtu.be/Ljy3qvtFzgo

编译安装Shadowsocks-libev服务端,AEAD加密算法支持 2022-4-5

段落1、需求描述

在服务器上通过apt-get install shadowsocks-libev安装了Shadowsocks,算法设置为aes-128-gcm,重启服务端,查看状态,发现

ERROR: Invalid cipher name: aes-128-gcm, use rc4-md5 instead

报错提示的意思是,加密算法,本版本的服务端不支持,用rc4-md5这个简单算法代替了

段落2、分析

查看服务器端的shadowsocks的版本

root@c501:~# ss-server -help
shadowsocks-libev 2.6.3 with mbed TLS 2.4.2

  maintained by Max Lv <max.c.lv@gmail.com> and Linus Yang <laokongzi@gmail.com>

  usage:

    ss-server

       -s <server_host>           Host name or IP address of your remote server.
       -p <server_port>           Port number of your remote server.
       -l <local_port>            Port number of your local server.
       -k <password>              Password of your remote server.
       -m <encrypt_method>        Encrypt method: table, rc4, rc4-md5,
                                  aes-128-cfb, aes-192-cfb, aes-256-cfb,
                                  aes-128-ctr, aes-192-ctr, aes-256-ctr,
                                  bf-cfb, camellia-128-cfb, camellia-192-cfb,
                                  camellia-256-cfb, cast5-cfb, des-cfb,
                                  idea-cfb, rc2-cfb, seed-cfb, salsa20 and
                                  chacha20.
                                  The default cipher is rc4-md5.

可以看到,我这台服务器上,通过apt-get install shadowsocks-libev安装的版本是2.6.3,支持的加密算法为

rc4, rc4-md5, aes-128-cfb, aes-192-cfb, aes-256-cfb, aes-128-ctr, aes-192-ctr, aes-256-ctr, bf-cfb, camellia-128-cfb, camellia-192-cfb, camellia-256-cfb, cast5-cfb, des-cfb, idea-cfb, rc2-cfb, seed-cfb, salsa20 and chacha20

简单点说,就是没有带AEAD算法的库, 自己编译安装一下就行

段落3、需补充安装的Mbed-TLS和libsodium两个项目的信息

libsodium 项目地址 https://github.com/jedisct1/libsodium

Mbed-TLS 项目地址 https://github.com/Mbed-TLS/mbedtls

Shadowsocks-libev 项目地址 https://github.com/shadowsocks/shadowsocks-libev

写这篇文章的时间是 2022-4-5 13:59,当前最新的版本

Mbed-TLS 2.28.0,这个用2.X.X的最高版本

https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v2.28.0.tar.gz

libsodium 1.0.18

https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz

shadowsocks-libev 3.3.5

https://github.com/shadowsocks/shadowsocks-libev/releases/download/v3.3.5/shadowsocks-libev-3.3.5.tar.gz

段落4、实施部署

安装必要的依赖

apt-get update
apt-get install gettext build-essential unzip gzip python3 curl openssl libssl-dev autoconf automake libtool gcc make perl cpio libpcre3 libpcre3-dev zlib1g-dev libev-dev libc-ares-dev

下载源代码

mkdir -p /root/src

cd /root/src/

# Mbed-TLS 2.28.0
wget https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v2.28.0.tar.gz
# libsodium 1.0.18
wget https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz
# shadowsocks-libev 3.3.5
wget https://github.com/shadowsocks/shadowsocks-libev/releases/download/v3.3.5/shadowsocks-libev-3.3.5.tar.gz
# 安装 Mbed-TLS 2.28.0
cd /root/src
tar -zxf v2.28.0.tar.gz
cd mbedtls-2.28.0
make SHARED=1 CFLAGS=-fPIC
make DESTDIR=/usr install
# 安装 libsodium 1.0.18
cd /root/src
tar -zxf libsodium-1.0.18.tar.gz
cd libsodium-1.0.18
./configure --prefix=/usr && make && make install
ldconfig -p
echo '/usr/lib' > /etc/ld.so.conf.d/usr_lib.conf
ldconfig
# 安装 shadowsocks-libev 3.3.5
mkdir -p /etc/shadowsocks-libev
cd /root/src
tar -zxf shadowsocks-libev-3.3.5.tar.gz
cd shadowsocks-libev-3.3.5
./configure --prefix=/usr --disable-documentation && make && make install
# 配置服务,修改配置文件,设置开机启动
创建 /etc/systemd/system/shadowsocks-libev.service

[Unit]
Description=Shadowsocks-libev Default Server Service
After=network-online.target network-online.target 

[Service]
Type=simple
LimitNOFILE=32768
ExecStart=/usr/bin/ss-server -c /etc/shadowsocks-libev/config.json
CapabilityBoundingSet=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
# 服务端的一个示例配置 /etc/shadowsocks-libev/config.json
{
    "server":["[::0]", "0.0.0.0"],
    "server_port":16805,
    "local_port":1080,
    "password":"P1122330099",
    "timeout":60,
    "method":"aes-128-gcm",
    "nameserver":"1.1.1.1",
    "mode":"tcp_only",
    "ipv6_first": true
}
# 如果不需要IPv6优先,则把对应规则删除即可
# 如果仅需要IPv4,监听为"0.0.0.0"
# 如果要UDP,则mode为 tcp_and_udp
# 服务端的一个示例配置 /etc/shadowsocks-libev/config.json
{
    "server":"0.0.0.0",
    "server_port":16805,
    "local_port":1080,
    "password":"P1122330099",
    "timeout":60,
    "method":"aes-128-gcm",
    "nameserver":"1.1.1.1",
    "mode":"tcp_and_udp"
}
# 如果不需要IPv6优先,则把对应规则删除即可
# 如果仅需要IPv4,监听为"0.0.0.0"
# 如果要UDP,则mode为 tcp_and_udp
# 如果需求为,国内服务器的,国内代理,nameserver需为国内的DNS服务器
# 服务端的一个示例配置 /etc/shadowsocks-libev/config.json
{
    "server":"0.0.0.0",
    "server_port":16805,
    "local_port":1080,
    "password":"P1122330099",
    "timeout":60,
    "method":"aes-128-gcm",
    "nameserver":"114.114.114.114",
    "mode":"tcp_and_udp"
}
支持的加密算法
Encrypt method: rc4-md5,
aes-128-gcm, aes-192-gcm, aes-256-gcm,
aes-128-cfb, aes-192-cfb, aes-256-cfb,
aes-128-ctr, aes-192-ctr, aes-256-ctr,
camellia-128-cfb, camellia-192-cfb,
camellia-256-cfb, bf-cfb,
chacha20-ietf-poly1305,
xchacha20-ietf-poly1305,
salsa20, chacha20 and chacha20-ietf.
The default cipher is chacha20-ietf-poly1305

附录1、可能的报错

checking whether mbedtls supports Cipher Feedback mode or not… configure: error: MBEDTLS_CIPHER_MODE_CFB required

这个报错,说明mbedtls没有安装,或者mbedtls 没有用对2.X.Y版本

附录2、参考链接
参考链接 https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh
参考链接 https://github.com/shadowsocks/shadowsocks-libev/issues/663

配置基于IPv6优先的Shadowsocks-libev,可供流量落地,解锁流媒体的需求 2022-3-27

需求描述:

配置SS,基本是用于接入层,或者落地层,满足接入层的客户端轻量化,满足落地层的简单化。

其他相关Dasmz的文章

000079. 基于sjlleo的netflix-verify,检测VPS服务器IP地址或节点IP是否支持Netflix流媒体 2022-2-28 检测节点的IPv6是否可用于Netflix流媒体,实际呢,检测脚本相对滞后,大家还是需要根据部署后,实际用落地进行播放来验证。 https://dasmz.com/?p=1522

000081. 基于双栈服务器的原生IPv6地址,解锁当地Netflix HBO等流媒体 2022-03-03 这篇是用V2ray配置IPv6出站,配置参数,对于普通人而言,比较复杂。 https://dasmz.com/?p=1583

Debian/Ubuntu安装

apt-get update
apt-get install shadowsocks-libev

修改服务器上的配置文件 /etc/shadowsocks-libev/config.json,配置IPv6和IPv4的Shadowsocks,这样双栈的服务端。

{
    "server":["[::0]", "0.0.0.0"],
    "server_port":12345,
    "local_port":1080,
    "password":"Pe611AbD",
    "timeout":60,
    "method":"aes-128-cfb",
    "nameserver":"1.1.1.1",
    "mode":"tcp_only",
    "ipv6_first": true
}
参数释义
{
    "server":["[::0]", "0.0.0.0"], // 服务器的监听地址,这里是IPv4/IPv6双栈
    "server_port":12345,    // 服务器的监听端口
    "local_port":1080,      // 
    "password":"Pe611AbD",  // 密码
    "timeout":60,           // 超时的时间,秒
    "method":"aes-128-cfb", // 加密算法
    "nameserver":"1.1.1.1", // 默认的DNS服务器,可选参数
    "mode":"tcp_only",      // 工作模式,我这里限制它为TCP,可选参数
    "ipv6_first": true      // 是否IPv6优先,本次落地场景必须加上
}
修改配置文件后,重启服务,即可生效

systemctl restart shadowsocks-libev

基于上面这个配置参数,双栈入站,IPv6出站优先的策略,可以解锁很多的流媒体站点。

000087. 配置基于IPv6优先的Shadowsocks-libev,可供流量落地,解锁流媒体的需求 2022-3-27

本期博客地址 https://dasmz.com/?p=1804
本期视频地址 https://youtu.be/7a2ccbHsUhY

Firefox,火狐浏览器,安装adblock或ublock广告拦截插件的问题 2022-3-21

段落1、需求描述

国内地区,使用火狐浏览器,装adblock或ublock广告拦截插件的问题

段落2、版本问题,本次会用国际版本作为示例

这里还有一个延伸的问题,火狐有一个常规的国际版本,和一个本地化的国内版本,两个版本数据是不通的。

区别如下

国际版本火狐是由 Mozilla 基金会 维护的

中国版本火狐是由 北京谋智火狐信息技术有限公司 维护的
国内版本,因某些原因,会有访问内容过滤,而且有广告
国内版火狐打开后会是一个类似hao123网页导航样式的页面

国际版火狐打开后显示的是一个搜索框和最近历史。
国内版 https://www.firefox.com.cn/
国际版 https://www.mozilla.org/en-US/firefox/new/

国际版本,在国内,下载速度较慢,需较好的网络环境,下载在线安装包,或者提前下载好离线安装包:

https://www.mozilla.org/en-US/firefox/all/#product-desktop-release

区别很好看出来

国内版的账号叫火狐通行证,国际版的叫Firefox Sync

段落3、无法安装adblock或ublock广告拦截插件的问题

在安装此类广告拦截插件的时候,提示在您所在的地区不可用

图像

根据网络消息,可能与法律诉讼

新闻链接:

截图存档,防源删,侵权可联系。

段落4、安装ublock/adblock插件

Firefox目前是根据GeoIP的IP地址数据库,屏蔽了中国IP地址下载这类广告拦截插件。

解决办法很简单,开启代理,只要不是CN地区的IP地址,可轻松下载。

苹果iOS,Shadowrocket进阶,基于小火箭自定义规则,配置广告拦截或者IP拦截 20220317

场景描述

在苹果手机,safari打开某小说网站时候,出现较多的广告,而且都是用色情的动图方式引流的广告链接

需求就很简单,把这些乱七八糟的广告屏蔽即可,这里使用的工具就是shadowrocket

实施操作步骤

1、打开Shadowrocket,打开下发菜单的第三个“数据”,打开末尾的”自动删除”,”代理”,”DNS”三个选项的开关

2、打开”首页”,全局路由那里选择默认的”配置”,选择某个节点连接

3、打开safari浏览器,发送小说网站的请求,在[数据/代理]最新的日志中,根据时间线,查看对应的广告域名。

4、打开[配置/default.conf右侧/规则/加号],进行广告域名屏蔽。

广告域名屏蔽的方式一般为

大广告联盟的域名,一般匹配到domain-对应子域名

小广告链接,一般屏蔽它的整个域名后缀domain-suffix/domainname

添加屏蔽后,规则是热加载的,不用重启节点,直接去浏览器刷新页面即可。

附录1、说明

视频教程中的网站,最后折腾我许久的那个广告图片,它的链接是
https://m.bige3.com/images/bfq/07.gif
这个动图确实是在其主站服务器上,无法通过简单的域名进行屏蔽。
可以点击图片下发的"点击关闭阅读广告"即可关闭。
这个网站相对比较良心,支持关闭广告。给其站长233个赞!

附录2、说明

一般,不是太确定的域名,不要用domain-suffix进行屏蔽,杀伤范围太大,容易造成错误。

视频

基于aircrack-ng跑无线信号WIFI的握手包密码,可无需字典文件 2022-3-16

段落1、需求描述

跑包,可选密码,或者自定义密码,或者无字典文件,用随机字符串

段落2、部署安装

apt-get update
apt-get install aircrack-ng cpulimit screen crunch

段落3、生成字典

根据实际的需求,自己生成字典文件,下面是8位的数字的字典,大约860MB

#!/usr/bin/python3
# 从00000000 - 99999999的字典,一共1千万个记录,文件大小约为860MB
d = '/root/DICT_8_DIGITAL.txt'
end = 100000000
with open(d,'w') as f:
    for i in range(0,end):
        f.write("%08d\n" % i)

可以发现,其实密码字典,还是很大的,如果要全部生成,很不划算,占用磁盘空间很多

段落4、开启跑包

screen -dmS SAirCrack aircrack-ng -w ./DICT_8_DIGITAL.txt -b B8:AA:08:10:D1:AA WPA_cap-01.cap

段落5、开始CPU限制

查找进程号
ps -ef | grep aircrack-ng

发现进程号
83623

开启CPU利用限制
screen -dmS SCPULimit cpulimit --pid 83623 --limit 60 

段落6、无字典,随机字符跑包

用crunch,命令大概如下

crunch 8 15 qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890 | aircrack-ng WPA_cap-01.cap -b B8:AA:08:10:D1:AA -w-

由于自己把跑包,放在云服务器上面,性能限制,速度慢很多,还是推荐用显卡跑,或者现代一点的,根据万能钥匙匹配。

随机8位[0-9a-zA-Z]字符的总数为62的8次方个组合,共计 218340105584896

假设碰撞速度为 180000,显卡运算,最大需要38.46年,才能碰撞到密码

>>> 218340105584896 / 180000 / 3600 / 24 / 365
38.46

000088. 基于aircrack-ng跑无线信号WIFI的握手包密码,可无需字典文件 2022-4-1

本期博客地址 https://dasmz.com/?p=1749
本期视频地址 https://youtu.be/xFrSVniOJkQ

配置haproxy负载均衡,落地到多socks4/socks5场景的配置 2022-3-16

段落1、需求描述

从网络上采集到很多个socks4/socks5透明代理,需要设置一个负载均衡,让流量走他们自动负载。

段落2、负载均衡haproxy是一个优秀的选项,本次就用它了

段落3、实施部署

服务器Backend1 开启一个socks5,命令如下
screen -dmS tmpS5 /root/gost-linux-amd64-2.11.1 -L=socks5://socks自定义用户名:socks自定义密码@0.0.0.0:16803

公网可用 socks5://socks自定义用户名:socks自定义密码@服务器Back1st的IP地址:16803
服务器Backend2 开启一个socks5,命令如下
screen -dmS tmpS5 /root/gost-linux-amd64-2.11.1 -L=socks5://socks自定义用户名:socks自定义密码@0.0.0.0:6403

公网可用 socks5://socks自定义用户名:socks自定义密码@服务器Back2ed的IP地址:6403

段落4、Ubuntu 20.04系统环境,安装部署haproxy

apt-get update
apt-get install haproxy

版本信息 haproxy -v
HA-Proxy version 2.0.13-2ubuntu0.5 2022/03/02

配置文件 /etc/haproxy/haproxy.cfg
服务名称 haproxy.service
检查配置文件语法 haproxy -c -f /etc/haproxy/haproxy.cfg
重启服务 systemctl restart haproxy
参数
* global 全局参数设置
* defaults 默认参数设置
* log 日志
* mode 工作模式,可选http tcp
* option 可选参数,如httplog forwardfor-记录客户端真实的IP httpclose-完成后主动关闭此TCP连接 dontlognull
* timeout connect 连接超时选项,成功连接到一台服务器的最长等待时间,默认单位是毫秒
* timeout client 连接超时选项,连接客户端发送数据时最长等待时间,默认单位是毫秒
* timeout server 连接超时选项,服务器端回应客户端数据发送的最长等待时间,默认单位是毫秒
* timeout check 连接超时选项,设置对后端服务器的检测超时时间,默认单位是毫秒
* frontend 入口
* backend 出口
* maxconn 可接受的最大并发连接数
* nbproc 在server服务端的haproxy进程数,建议根据小于等于CPU核心数设置
* daemon 后台模式,运行后会后台常驻
* user/group 启动的工作态的用户和组
* pidfile 进程pid位置
* balance 支持的负载均衡算法
roundrobin 基于权重进行轮叫调度的算法
static-rr 基于权重进行轮叫调度的算法,不过此算法为静态算法
source 基于请求源IP的算法。此算法先对请求的源IP进行HASH运算,然后将结果与后端服务器的权重总数相除后转发至某台匹配的后端服务器。这种方式可以使同一个客户端IP的请求始终转发到某特定的后端服务器
leastconn 此算法会将新的连接请求转发到具有最少连接数目的后端服务器。在会话时间较长的场景中推荐使用此算法
uri 此算法会对部分或整个URI进行HASH运算,再经过与服务器的总权重相除,最后转发到某台匹配的后端服务器上
uri_param 此算法会根据URL路径中的参数进行转发,这样可保证在后端真实服务器数据不变时,同一个用户的请求始终分发到同一台机器上
hdr 此算法根据HTTP头进行转发,如果指定的HTTP头名称不存在,则使用roundrobin算法 进行策略转发

后端的param参数
常用的参数:
check 表示启用对此后端服务器执行健康状态检查
inter 设置健康状态检查的时间间隔,单位是毫秒
rise 检查多少次认为服务器可用
fall 检查多少次认为服务器不可用
weight 设置服务器的权重,默认为1, 最大为256。 设置为0表示不参与负载均衡
backup 设置备份服务器,用于所有后端服务器全部不可用时
cookie 为指定的后端服务器设置cookie值,此处指定的值将在请求入站时被检查,第一次为此值挑选的后端服务器将在后续的请求中一直被选中,其目的在于实现持久连接的功能
参考的一个配置
defaults
        log global
        mode    tcp
        option  tcplog
        timeout connect  60000
        timeout client  120000
        timeout server  120000


frontend roubin_socks5_listen
        mode    tcp
        bind    *:31111
        default_backend roubin_socks5_outbound

backend roubin_socks5_outbound
        mode    tcp
        balance roundrobin
        server server1 服务器Back1st的IP地址:16803 check inter 8000 rise 2 fall 3 maxconn 512
        server server2 服务器Back2ed的IP地址:6403 check inter 8000 rise 2 fall 3 maxconn 512

段落5、验证可用

proxychains4 curl http://ip.sb

附录1、可选,增加统计页面

listen stats
        mode http
        bind 0.0.0.0:8888
        stats refresh 30s
        stats enable
        stats uri     /stats 
        stats auth    haproxy:2fCb2a0Ea3d15E9a


可以通过 http://你服务器的IP地址:8888/stats访问

— 2022-3-23 更新

用代码从数据库中提取可用的socks4/socks5节点,添加到haproxy配置文件中

多socks4/socks5的场景

统计页面的显示

这样,自己只需要连接 haproxy生成的 roubin_inbound入口端口即可,后端差错控制由haproxy负责,棒!