NG Proxy 支持
为你的 Minecraft Forge 服务器添加 HAProxy PROXY 协议支持。
当你的服务器位于 Velocity、TCPShield、FRP、Nginx 或其他任何兼容 HAProxy 的反向代理后面时,查看真实的玩家 IP 地址。
功能特性
- HAProxy PROXY Protocol v1/v2 — 完全支持两种协议版本
- 真实 IP 解析 — 通过代理连接的玩家将在服务器日志、封禁列表和插件中显示其真实 IP
- 混合模式 — 同时支持代理连接和直连
- 故障关闭安全机制 — 来自未知 IP 的连接会被自动拒绝,防止绕过代理攻击
- CIDR 表示法 — 允许整个子网(例如
192.168.0.0/16)加入白名单
- TCPShield 集成 — 自动获取并将 TCPShield 服务器 IP 加入白名单
- 热重载配置 — 无需重启服务器即可重新加载配置
- 状态命令 — 在游戏中查看当前配置和连接统计信息
- 连接日志记录 — 将真实玩家 IP 和代理 IP 记录到专用的日志文件中
命令
| 命令 |
权限 |
描述 |
/proxyprotocol reload |
OP 等级 4 |
不重启服务器重新加载配置 |
/proxyprotocol status |
OP 等级 4 |
查看当前配置和活动规则 |
配置
配置文件:config/proxy_protocol_support.json
{
"enableProxyProtocol": true,
"proxyServerIPs": ["127.0.0.1"],
"directAccessIPs": ["127.0.0.1", "192.168.0.0/16"],
"whitelistTCPShieldServers": false,
"logConnections": true
}
| 选项 |
描述 |
enableProxyProtocol |
启用或禁用整个模组 |
proxyServerIPs |
你的代理服务器 IP(Velocity、HAProxy 等)—— 仅接受来自这些 IP 的 PROXY 头信息 |
directAccessIPs |
允许直接连接而不带 PROXY 头信息的 IP |
whitelistTCPShieldServers |
自动获取 TCPShield IP 并将其添加到代理白名单中 |
logConnections |
将真实 IP 和代理 IP 记录到 logs/proxy_connections.log |
工作原理
玩家 → 代理 (Velocity/HAProxy/FRP) → Forge 服务器 (带有 NG Proxy Support)
↓
读取 PROXY 头信息
提取真实 IP
设置玩家地址
- 你的代理发送包含真实客户端 IP 的 PROXY 协议头
- NG Proxy Support 拦截传入的连接并读取该头信息
- 玩家的地址被设置为其 真实 IP 而非代理 IP
- 所有服务器日志、封禁系统和插件都能看到正确的 IP
安全模型
NG Proxy Support 采用 故障关闭 模型:
- ✅ 来自
proxyServerIPs 的连接 → 读取 PROXY 头信息,提取真实 IP
- ✅ 来自
directAccessIPs 的连接 → 无需 PROXY 头信息即可访问
- ❌ 来自 任何其他 IP 的连接 → 自动 拒绝
这可以防止玩家绕过你的代理直接连接并伪造其 IP。
设置指南
使用 Velocity
- 在你的 Forge 服务器上安装 NG Proxy Support
- 在 Velocity 的
velocity.toml 中启用 PROXY 协议:
[advanced]
haproxy-protocol = true
- 将你的 Velocity 服务器 IP 添加到模组的
proxyServerIPs 配置中
- 重启两个服务器
使用 HAProxy / Nginx / FRP
- 配置你的反向代理以发送 PROXY 协议头信息
- 将代理 IP 添加到
proxyServerIPs
- 重启 Forge 服务器
要求
- Minecraft 1.20.1
- Forge 47.x
- Java 17+
- 仅限服务端(不需要客户端模组)
致谢
由 xylos 制作 | © 2024-2026 版权所有
NG Proxy Support
Adds HAProxy PROXY protocol support to your Minecraft Forge server.
See real player IP addresses when your server is behind a proxy like Velocity, TCPShield, FRP, Nginx, or any other HAProxy-compatible reverse proxy.
Features
- HAProxy PROXY Protocol v1/v2 — Full support for both protocol versions
- Real IP Resolution — Players connecting through a proxy will show their real IP in server logs, bans, and plugins
- Hybrid Mode — Supports both proxied and direct connections simultaneously
- Fail-Closed Security — Connections from unknown IPs are automatically rejected, preventing proxy bypass attacks
- CIDR Notation — Whitelist entire subnets (e.g.
192.168.0.0/16)
- TCPShield Integration — Automatically fetch and whitelist TCPShield server IPs
- Hot-Reload Config — Reload configuration without restarting the server
- Status Command — View current configuration and connection stats in-game
- Connection Logging — Log real player IPs and proxy IPs to a dedicated log file
Commands
| Command |
Permission |
Description |
/proxyprotocol reload |
OP Level 4 |
Reload config without restart |
/proxyprotocol status |
OP Level 4 |
View current config and active rules |
Configuration
Config file: config/proxy_protocol_support.json
{
"enableProxyProtocol": true,
"proxyServerIPs": ["127.0.0.1"],
"directAccessIPs": ["127.0.0.1", "192.168.0.0/16"],
"whitelistTCPShieldServers": false,
"logConnections": true
}
| Option |
Description |
enableProxyProtocol |
Enable/disable the mod entirely |
proxyServerIPs |
IPs of your proxy servers (Velocity, HAProxy, etc.) — PROXY headers will only be accepted from these IPs |
directAccessIPs |
IPs allowed to connect directly without PROXY headers |
whitelistTCPShieldServers |
Auto-fetch TCPShield IPs and add them to proxy whitelist |
logConnections |
Log real IP and proxy IP to logs/proxy_connections.log |
How It Works
Player → Proxy (Velocity/HAProxy/FRP) → Forge Server (with NG Proxy Support)
↓
Reads PROXY header
Extracts real IP
Sets player address
- Your proxy sends a PROXY protocol header with the real client IP
- NG Proxy Support intercepts incoming connections and reads the header
- The player's address is set to their real IP instead of the proxy IP
- All server logs, ban systems, and plugins see the correct IP
Security Model
NG Proxy Support uses a fail-closed model:
- ✅ Connections from
proxyServerIPs → PROXY header is read, real IP is extracted
- ✅ Connections from
directAccessIPs → Allowed without PROXY header
- ❌ Connections from any other IP → Automatically rejected
This prevents players from bypassing your proxy to connect directly and spoof their IP.
Setup Guide
With Velocity
- Install NG Proxy Support on your Forge server
- Enable PROXY protocol in Velocity's
velocity.toml:
[advanced]
haproxy-protocol = true
- Add your Velocity server IP to
proxyServerIPs in the mod config
- Restart both servers
With HAProxy / Nginx / FRP
- Configure your reverse proxy to send PROXY protocol headers
- Add the proxy IP to
proxyServerIPs
- Restart the Forge server
Requirements
- Minecraft 1.20.1
- Forge 47.x
- Java 17+
- Server-side only (no client mod needed)
Credits
Made by xylos | © 2024-2026 All rights reserved
评论 0
登录后参与评分
还没有评论,来抢沙发吧