WireGarud
注意事项
一个服务器分配多个许可证
如果是多个客户端使用同一个服务器端的配置文件, 那么需要修改[Interface]
下的Address
字段的值与其他客户端的CIDR
不同,
例如一个客户端是11.1.6.2/32
, 另一个客户端就不能使用该CIDR段, 可以使用10.10.10.2/32
这样的用于区分
[Interface]
PrivateKey = PrivateKey
Address = CIDR
DNS = 127.0.0.1, 192.168.2.1
[Peer]
PublicKey = PublicKey
PresharedKey = PresharedKey
AllowedIPs = AllowedIPs
Endpoint = Endpoint
PersistentKeepalive = 25
apt/apt-get
检查是否内置
wg -v
默认自带, 如果没有安装请手动安装:
apt install openresolv
apt install wireguard-tools
客户端样板代码:
cat > /etc/wireguard/wg0.conf <<EOF
[Interface]
PrivateKey = PrivateKey
Address = CIDR
DNS = 127.0.0.1, 192.168.2.1
[Peer]
PublicKey = PublicKey
PresharedKey = PresharedKey
AllowedIPs = AllowedIPs
Endpoint = Endpoint
PersistentKeepalive = 25
EOF
Nginx 代理
cat> /usr/local/nginx/conf/casdoor.conf <<EOF
server {
listen 8000;
http2 on;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Frame-Options SAMEORIGIN always;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "DENY";
add_header Alt-Svc 'h3=":443"; ma=86400, h3-29=":443"; ma=86400';
proxy_connect_timeout 5s;
# 添加 Early-Data 头告知后端,防止重放攻击
proxy_set_header Host \$host;
location / {
proxy_pass http://192.168.2.185:8000; # Kubernetes集群中应用的地址和端口
#roxy_set_header X-Real-IP \$remote_addr;
#roxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto \$scheme;
}
}
EOF
/usr/local/nginx/sbin/nginx -s reload
yum/dnf
dnf install wireguard-tools
Run the below command to start and enable the 'systemd-resolved' service.
运行以下命令以启动并启用“systemd 解析”服务。
sudo systemctl start systemd-resolved
sudo systemctl enable systemd-resolved