Configure networking properly for your FiveM server.
The following diagram shows how traffic flows through a typical FiveM server setup with a reverse proxy:
Network Flow:
Key Points:
| Port | Protocol | Purpose | Required For |
|---|---|---|---|
| 30120 | TCP/UDP | Game server | Players to join |
| 40120 | TCP | txAdmin web interface | Admin access (can be proxied) |
UFW (Uncomplicated Firewall) is the default firewall manager on Ubuntu and Debian:
# Allow game server traffic
sudo ufw allow 30120/tcp comment 'FiveM game server TCP'
sudo ufw allow 30120/udp comment 'FiveM game server UDP'
# Allow txAdmin (if not using reverse proxy)
sudo ufw allow 40120/tcp comment 'txAdmin web interface'
# Enable firewall
sudo ufw enable
# Verify rules
sudo ufw status numberedExpected Output:
Status: active
To Action From
-- ------ ----
[ 1] 30120/tcp ALLOW IN Anywhere
[ 2] 30120/udp ALLOW IN Anywhere
[ 3] 40120/tcp ALLOW IN AnywhereFor CentOS, RHEL, and Fedora systems using firewalld:
# Allow game server traffic
sudo firewall-cmd --permanent --add-port=30120/tcp
sudo firewall-cmd --permanent --add-port=30120/udp
sudo firewall-cmd --permanent --add-port=40120/tcp
# Reload firewall
sudo firewall-cmd --reload
# Verify rules
sudo firewall-cmd --list-portsExpected Output:
30120/tcp 30120/udp 40120/tcpConfigure Windows Firewall using PowerShell (run as Administrator):
# Allow FiveM game server
New-NetFirewallRule -DisplayName "FiveM Game Server" -Direction Inbound -LocalPort 30120 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "FiveM Game Server UDP" -Direction Inbound -LocalPort 30120 -Protocol UDP -Action Allow
# Allow txAdmin
New-NetFirewallRule -DisplayName "txAdmin Web Interface" -Direction Inbound -LocalPort 40120 -Protocol TCP -Action Allow
# Verify rules
Get-NetFirewallRule -DisplayName "*FiveM*","*txAdmin*" | Format-Table DisplayName, Enabled, Direction, ActionA reverse proxy sits between the internet and your txAdmin interface, providing:
Complete Nginx configuration with SSL termination, WebSocket support, and security headers:
# Redirect HTTP to HTTPS
server {
listen 80;
server_name your-domain.com;
return 301 https://$server_name$request_uri;
}
# HTTPS server
server {
listen 443 ssl http2;
server_name your-domain.com;
# SSL certificates (use Certbot for Let's Encrypt)
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
# SSL configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Proxy to txAdmin
location / {
proxy_pass http://127.0.0.1:40120;
# Essential proxy headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket support (for txAdmin real-time features)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
}Setting up SSL with Certbot:
# Install Certbot
sudo apt update
sudo apt install certbot python3-certbot-nginx
# Obtain certificate (Nginx will auto-configure)
sudo certbot --nginx -d your-domain.com
# Test auto-renewal
sudo certbot renew --dry-runCaddy automatically handles SSL certificates via Let’s Encrypt:
your-domain.com {
# Reverse proxy to txAdmin
reverse_proxy localhost:40120 {
# WebSocket support
header_up Connection {>Connection}
header_up Upgrade {>Upgrade}
}
# Security headers
header {
X-Frame-Options "SAMEORIGIN"
X-Content-Type-Options "nosniff"
X-XSS-Protection "1; mode=block"
}
}Why Caddy?
Installing Caddy:
# Ubuntu/Debian
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
# Start and enable
sudo systemctl enable --now caddyBenefits:
Most VPS providers offer DDoS protection:
Add rate limiting to prevent abuse:
# Define rate limit zone
limit_req_zone $binary_remote_addr zone=txadmin_limit:10m rate=10r/m;
server {
# ... existing config ...
location / {
limit_req zone=txadmin_limit burst=5 nodelay;
# ... proxy config ...
}
}From local machine:
# Test TCP port
nc -zv your-server-ip 30120
# Test UDP port (requires netcat with UDP support)
nc -u -zv your-server-ip 30120Expected Output (success):
Connection to your-server-ip 30120 port [tcp/*] succeeded!From server itself:
# Check if port is listening
sudo netstat -tulpn | grep 30120
# or
sudo ss -tulpn | grep 30120Expected Output:
tcp 0 0 0.0.0.0:30120 0.0.0.0:* LISTEN 12345/fxserver
udp 0 0 0.0.0.0:30120 0.0.0.0:* 12345/fxserverTest local connectivity:
# Should return txAdmin HTML
curl -I http://127.0.0.1:40120
# Test through proxy
curl -I https://your-domain.comCommon Issues:
502 Bad Gateway
systemctl status txadminSSL Certificate Errors
sudo certbot certificatesWebSocket Connection Failed
Upgrade and Connection headers in Nginx configAfter configuring networking:
Test game server connection:
your-server-ip:30120Test admin interface:
https://your-domain.com (or http://your-server-ip:40120 if no proxy)Verify firewall:
# UFW
sudo ufw status verbose
# firewalld
sudo firewall-cmd --list-allIf networking changes break connectivity:
Disable firewall temporarily:
# UFW
sudo ufw disable
# firewalld
sudo systemctl stop firewalldRestore Nginx/Caddy config:
# Nginx
sudo cp /etc/nginx/sites-available/backup.conf /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl reload nginx
# Caddy
sudo cp /etc/caddy/Caddyfile.backup /etc/caddy/Caddyfile
sudo systemctl reload caddyCheck server logs:
# FXServer logs
tail -f /opt/fivem/logs/server.log
# Nginx logs
sudo tail -f /var/log/nginx/error.log