Minecraft Server Setup Guide
Complete guide for setting up Minecraft servers with BungeeCord networks, reverse proxy configurations, and advanced security measures.
Requirements & Prerequisites
Important: Ensure you have sufficient system resources and proper network configuration before proceeding.
System Requirements
Minimum Requirements
- CPU: 2 cores (2.0 GHz)
- RAM: 2GB (4GB recommended)
- Storage: 5GB free space
- Network: 100 Mbps connection
Recommended Requirements
- CPU: 4+ cores (3.0+ GHz)
- RAM: 8GB+ (16GB for networks)
- Storage: SSD with 20GB+ space
- Network: Gigabit connection
Software Prerequisites
bash
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install Java 17 (recommended for newer MC versions)
sudo apt install openjdk-17-jre-headless -y
# Install screen for background processes
sudo apt install screen -y
# Create minecraft user
sudo useradd -m -d /opt/minecraft -s /bin/bash minecraft
Vanilla Server Setup
Download and Initial Setup
bash
# Switch to minecraft user
sudo su - minecraft
# Create server directory
mkdir ~/server
cd ~/server
# Download latest server jar (replace URL with current version)
wget https://launcher.mojang.com/v1/objects/c8f83c5655308435b3dcf03c06d9fe8740a77469/server.jar
# Create start script
cat > start.sh << 'EOF'
#!/bin/bash
java -Xmx4G -Xms1G -jar server.jar nogui
EOF
chmod +x start.sh
Initial Configuration
bash
# First run to generate files
./start.sh
# Accept EULA
echo "eula=true" > eula.txt
Server.properties Configuration
properties
# Basic server.properties settings
server-port=25565
server-ip=0.0.0.0
online-mode=true
max-players=20
motd=§aMrFaws Minecraft Server
difficulty=normal
gamemode=survival
pvp=true
spawn-protection=16
view-distance=10
simulation-distance=10
BungeeCord Network Setup
BungeeCord allows you to connect multiple Minecraft servers together, creating a network where players can seamlessly move between servers.
BungeeCord Installation
bash
# Create BungeeCord directory
mkdir ~/bungee
cd ~/bungee
# Download BungeeCord
wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar
# Create start script
cat > start.sh << 'EOF'
#!/bin/bash
java -Xmx512M -jar BungeeCord.jar
EOF
chmod +x start.sh
BungeeCord Configuration
yaml
# config.yml
player_limit: 100
ip_forward: true
prevent_proxy_connections: false
online_mode: true
servers:
lobby:
motd: '&aLobby Server'
address: localhost:25566
restricted: false
survival:
motd: '&bSurvival Server'
address: localhost:25567
restricted: false
creative:
motd: '&eCreative Server'
address: localhost:25568
restricted: false
listeners:
- query_port: 25577
motd: '&aMrFaws Network'
tab_list: GLOBAL_PING
query_enabled: false
proxy_protocol: false
forced_hosts:
pvp.example.com: pvp
ping_passthrough: false
priorities:
- lobby
bind_local_address: true
host: 0.0.0.0:25565
max_players: 100
tab_size: 60
force_default_server: false
Backend Server Configuration
Configure each backend server for BungeeCord:
properties
# server.properties for backend servers
online-mode=false
server-port=25566 # Different for each server
bungeecord=true
Reverse Proxy Setup
Nginx TCP Load Balancing
Configure Nginx to handle TCP connections for Minecraft:
nginx
# /etc/nginx/nginx.conf
stream {
upstream minecraft_backend {
server 127.0.0.1:25565 weight=1 max_fails=3 fail_timeout=10s;
server 127.0.0.1:25566 weight=1 max_fails=3 fail_timeout=10s backup;
}
server {
listen 25565;
proxy_pass minecraft_backend;
proxy_timeout 1s;
proxy_responses 1;
error_log /var/log/nginx/minecraft.log;
}
# BungeeCord load balancing
upstream bungee_backend {
least_conn;
server 127.0.0.1:25565;
server 127.0.0.1:25575;
}
server {
listen 25577;
proxy_pass bungee_backend;
proxy_timeout 1s;
proxy_responses 1;
}
}
HAProxy Alternative
config
# /etc/haproxy/haproxy.cfg
global
daemon
maxconn 4096
defaults
mode tcp
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend minecraft_frontend
bind *:25565
default_backend minecraft_servers
backend minecraft_servers
balance roundrobin
option tcp-check
server mc1 127.0.0.1:25566 check
server mc2 127.0.0.1:25567 check backup
Plugin Management
Essential Security Plugins
AuthMe
Advanced authentication and registration system
wget -O plugins/AuthMe.jar https://ci.codemc.org/job/AuthMe/job/AuthMeReloaded/lastSuccessfulBuild/artifact/target/AuthMe-5.6.0-SNAPSHOT.jar
CoreProtect
Block logging and rollback protection
wget -O plugins/CoreProtect.jar https://www.spigotmc.org/resources/coreprotect.8631/download
Performance Plugins
ClearLag
Automatic entity and item cleanup
Dynmap
Real-time web-based world map
Security & Protection
Firewall Configuration
bash
# UFW firewall rules
sudo ufw enable
sudo ufw allow ssh
sudo ufw allow 25565/tcp # Minecraft
sudo ufw allow 25577/tcp # BungeeCord
sudo ufw allow 8123/tcp # Dynmap (if used)
# Rate limiting for DDoS protection
sudo ufw limit 25565/tcp
DDoS Protection with iptables
bash
# Advanced DDoS protection
sudo iptables -A INPUT -p tcp --dport 25565 -m connlimit --connlimit-above 5 -j DROP
sudo iptables -A INPUT -p tcp --dport 25565 -m recent --set --name minecraft
sudo iptables -A INPUT -p tcp --dport 25565 -m recent --update --seconds 60 --hitcount 10 --name minecraft -j DROP
# Save rules
sudo iptables-save > /etc/iptables/rules.v4
Fail2Ban Configuration
ini
# /etc/fail2ban/jail.local
[minecraft]
enabled = true
port = 25565
filter = minecraft
logpath = /opt/minecraft/server/logs/latest.log
maxretry = 5
bantime = 3600
findtime = 600
Performance Optimization
JVM Tuning
bash
# Optimized start script
#!/bin/bash
java -Xmx8G -Xms8G \
-XX:+UseG1GC \
-XX:+ParallelRefProcEnabled \
-XX:MaxGCPauseMillis=200 \
-XX:+UnlockExperimentalVMOptions \
-XX:+DisableExplicitGC \
-XX:+AlwaysPreTouch \
-XX:G1NewSizePercent=30 \
-XX:G1MaxNewSizePercent=40 \
-XX:G1HeapRegionSize=8M \
-XX:G1ReservePercent=20 \
-XX:G1HeapWastePercent=5 \
-XX:G1MixedGCCountTarget=4 \
-XX:InitiatingHeapOccupancyPercent=15 \
-XX:G1MixedGCLiveThresholdPercent=90 \
-XX:G1RSetUpdatingPauseTimePercent=5 \
-XX:SurvivorRatio=32 \
-XX:+PerfDisableSharedMem \
-XX:MaxTenuringThreshold=1 \
-Dusing.aikars.flags=https://mcflags.emc.gs \
-Daikars.new.flags=true \
-jar server.jar nogui
Server Configuration Optimization
yaml
# bukkit.yml optimizations
settings:
allow-end: true
warn-on-overload: true
permissions-file: permissions.yml
update-folder: update
plugin-profiling: false
connection-throttle: 4000
query-plugins: true
deprecated-verbose: default
shutdown-message: Server closed
spawn-limits:
monsters: 70
animals: 10
water-animals: 15
ambient: 15
chunk-gc:
period-in-ticks: 600
load-threshold: 0
ticks-per:
animal-spawns: 400
monster-spawns: 1
autosave: 6000
Paper.yml Optimizations
yaml
# paper.yml performance settings
world-settings:
default:
max-auto-save-chunks-per-tick: 24
optimize-explosions: true
mob-spawner-tick-rate: 1
game-mechanics:
disable-chest-cat-detection: true
anti-xray:
enabled: true
engine-mode: 1
max-chunk-section-index: 3
update-radius: 2
lava-obscures: false
use-permission: false
Monitoring & Logging
Log Management
bash
# Create log rotation script
cat > /opt/minecraft/rotate_logs.sh << 'EOF'
#!/bin/bash
cd /opt/minecraft/server/logs
gzip latest.log
mv latest.log.gz "minecraft-$(date +%Y%m%d).log.gz"
find . -name "*.log.gz" -mtime +30 -delete
EOF
# Add to crontab
echo "0 4 * * * /opt/minecraft/rotate_logs.sh" | crontab -
Performance Monitoring Script
bash
# Server monitoring script
#!/bin/bash
while true; do
echo "$(date): Players online: $(screen -S minecraft -Q windows | wc -l)"
echo "$(date): Memory usage: $(free -h | grep Mem | awk '{print $3}')"
echo "$(date): CPU load: $(uptime | awk -F'load average:' '{print $2}')"
echo "---"
sleep 60
done > /opt/minecraft/monitor.log &
Troubleshooting
Common Issues and Solutions
Server Won't Start
Check:
- Java installation and version
- EULA acceptance
- Port availability
- Available memory
java -version
netstat -tulpn | grep :25565
free -h
Connection Issues
Troubleshoot:
- Firewall rules
- Port forwarding
- Server IP binding
- DNS resolution
sudo ufw status
telnet server-ip 25565
Performance Issues
Check:
- Memory allocation
- CPU usage
- Disk I/O
- Plugin conflicts
top -p $(pgrep java)
iotop
/timings report
BungeeCord Issues
Verify:
- Backend server online-mode=false
- IP forwarding enabled
- Server addresses in config
- Network connectivity
grep "online-mode" server.properties
grep "ip_forward" config.yml
Useful Commands
Server Management
# Start server in screen
screen -S minecraft ./start.sh
# Attach to running server
screen -r minecraft
# Stop server gracefully
screen -S minecraft -X stuff "stop$(echo -ne '\r')"
Log Analysis
# View recent errors
tail -f logs/latest.log | grep ERROR
# Check player connections
grep "logged in" logs/latest.log
# Monitor performance
grep "Can't keep up" logs/latest.log