安全防护
This commit is contained in:
1 parent
1daf477899
commit
98657ace5b
25 files changed
+570
-4
No files matched your search
@@ -0,0 +1,32 @@
|
||||
# nftables 配置模板,不能原样部署:必须替换服务 UID 并填入所有业务目标。
|
||||
# 仅约束专用 Java 服务用户的出站流量,不清空现有防火墙规则。
|
||||
# 其他出站链仍可进一步拒绝本表放行的流量。需同时检查容器网络/转发路径。
|
||||
define service_uid = 99999
|
||||
table inet usdt_egress {
|
||||
set dns4 { type ipv4_addr; flags interval; }
|
||||
set dns6 { type ipv6_addr; flags interval; }
|
||||
set business4 { type ipv4_addr; flags interval; }
|
||||
set business6 { type ipv6_addr; flags interval; }
|
||||
set database4 { type ipv4_addr; flags interval; }
|
||||
set database6 { type ipv6_addr; flags interval; }
|
||||
chain output {
|
||||
type filter hook output priority 10; policy accept;
|
||||
meta skuid $service_uid jump java_egress
|
||||
}
|
||||
chain java_egress {
|
||||
# 保留现有连接的返回流量;应用应在规则生效后重启,避免保留旧恶意出站连接。
|
||||
ct state established,related accept
|
||||
oifname "lo" accept
|
||||
ip daddr @dns4 udp dport 53 accept
|
||||
ip6 daddr @dns6 udp dport 53 accept
|
||||
ip daddr @dns4 tcp dport 53 accept
|
||||
ip6 daddr @dns6 tcp dport 53 accept
|
||||
ip daddr @database4 tcp dport { 3306, 6379 } accept
|
||||
ip6 daddr @database6 tcp dport { 3306, 6379 } accept
|
||||
# 端口按实际服务配置调整;IP 集合包含 RPC、执行器、回调、OAuth 等业务目标。
|
||||
ip daddr @business4 tcp dport { 80, 443, 50051, 50061 } accept
|
||||
ip6 daddr @business6 tcp dport { 80, 443, 50051, 50061 } accept
|
||||
limit rate 5/second log prefix "usdt-egress-denied "
|
||||
counter reject
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# 复制到 /etc/nginx/snippets/usdt-admin-allow.conf。
|
||||
# 仅在此处添加实际管理员公网 IP / VPN 网段;不要放行 0.0.0.0/0。
|
||||
allow 127.0.0.1;
|
||||
allow ::1;
|
||||
deny all;
|
||||
@@ -0,0 +1,16 @@
|
||||
# 合并到现有对外 server 中。使用 /prod-api 前缀的若依部署与直接路径均覆盖。
|
||||
# 必须放在其他正则 location 前,且不能被现有 ^~ /prod-api/ 或精确 location 绕过。
|
||||
# 合并后使用 nginx -T 核对实际命中的 location,再 nginx -t。
|
||||
# 若前面还有 CDN/LB,仅对可信代理设置 real_ip;禁止信任全网的转发头。
|
||||
location ~ ^/(?:prod-api/)?(?:monitor/(?:job|jobLog)|druid)(?:[/.;]|$) {
|
||||
include /etc/nginx/snippets/usdt-admin-allow.conf;
|
||||
# 与现有网关相同的 URI 去前缀行为,保留查询串。
|
||||
rewrite ^/prod-api/(.*)$ /$1 break;
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
# 如需整个管理站仅限 VPN,在独立管理域名的 server 级 include 上面的 allow 文件;
|
||||
# 对外支付 API / OAuth 回调 / Telegram webhook 继续放在原公共 server,避免误封业务。
|
||||
Reference in new issue
Block a user