-
-
Notifications
You must be signed in to change notification settings - Fork 310
How to protect game servers UDP port traffic using Nginx
Conor McKnight edited this page May 5, 2026
·
4 revisions
You can use Nginx to protect UDP traffic from DDoS attacks its not just for web based traffic what uses TCP ports.
Here is a example of how you can protect game servers that run on UDP ports using Nginx to prevent DDoS attacks it can be Minecraft, Counter Strike, Team fortress PUBG etc.
stream {
# Memory Zone to Limit concurrent connections per IP
limit_conn_zone $binary_remote_addr zone=udp_addr:100m;
# Upstream to your internal Steam game server
upstream game_servers {
hash $remote_addr:$remote_port consistent; # Ensures consistent routing
server 127.0.0.1:27020; # Replace with your game server internal IP make sure the port game server uses is private and not public Nginx should be the only public port
}
server {
listen 27015 udp reuseport; # Listen on UDP 27015
proxy_pass game_servers;
# Optimization for game traffic
proxy_timeout 60s;
proxy_responses 0; # Important: Forward all responses
# Limit connections per IP address to 10 Connections.
limit_conn udp_addr 10;
# Limit speed to 50k per second
proxy_download_rate 50k;
proxy_upload_rate 50k;
}
}