Forced Hosts Configuration
ForcedHosts allows you to route players to specific backend servers based on the hostname they use to connect to your Gate proxy. This enables multiple domains to point to the same proxy but direct players to different servers.ForcedHosts is available in classic mode (when
lite.enabled: false). For lightweight deployments, see Gate Lite Mode which provides similar host-based routing with advanced load balancing.How It Works
When a player connects to your Gate proxy, the client sends the hostname they used in the initial handshake packet. Gate examines this hostname and routes the player based on your ForcedHosts configuration.Configuration
Map of hostnames to server name lists. Keys are hostnames (case-insensitive), values are arrays of server names for load balancing.
Key Features
Hostname-Only Matching
Port numbers are ignored -
creative.example.com:25565 matches creative.example.comCase-Insensitive
Creative.Example.COM matches creative.example.comLoad Balancing
List multiple servers per hostname for distribution
Automatic Fallback
Uses
try list when no forced host matchesBasic Configuration
Simple Domain Routing
Route different domains to different game modes:config.yml
Load Balancing Setup
Distribute players across multiple servers for the same hostname:config.yml
Gate tries servers in order from the list. For advanced load balancing strategies (random, round-robin, least-connections), use Gate Lite mode.
Advanced Examples
Multi-Domain Network
Support multiple domains and aliases for a large server network:config.yml
Development and Production
Separate development and production environments:config.yml
Mixed Load Balancing Strategy
Combine load balancing with single servers:config.yml
DNS Configuration
For ForcedHosts to work, configure DNS records to point all domains to your Gate proxy IP:Behavior and Matching
Understanding how Gate matches hostnames:Matching Rules
- Port Ignored -
example.com:25565matchesexample.com - Case Insensitive -
Example.COMmatchesexample.com - Exact Match - No wildcard or regex support
- Virtual Host Cleaning - Handles Forge FML separators automatically
- IP Addresses - Raw IP connections don’t match, use try list
Connection Examples
Given this configuration:| Player Connects To | Routes To | Reason |
|---|---|---|
creative.example.com:25565 | creative-server | Matches forced host |
CREATIVE.EXAMPLE.COM:25565 | creative-server | Case-insensitive match |
survival.example.com:12345 | survival-server | Port ignored, hostname matches |
other.example.com:25565 | lobby-server | No match, uses try list |
192.168.1.100:25565 | lobby-server | IP address, uses try list |
example.com:25565 | lobby-server | No match, uses try list |
Forge/FML Handling
Forge clients append\x00FML\x00 to virtual host. Gate automatically strips this before matching:
Load Balancing Behavior
When multiple servers are listed for a hostname:- Attempts connection to
lobby-1 - If
lobby-1is offline or fails, trieslobby-2 - If
lobby-2is offline or fails, trieslobby-3 - If all fail, uses try list or disconnects player
Complete Example
A full configuration for a multi-server network with forced hosts:config.yml
Troubleshooting
Players not routing correctly
Players not routing correctly
Problem: Players connecting to
creative.example.com end up on wrong serverDiagnosis:- Enable debug logging:
debug: true - Check logs for hostname Gate receives
- Verify DNS points to Gate proxy
- Test with
/connect creative.example.com(if different result, it’s DNS)
- DNS not pointing to Gate
- Hostname mismatch (check case, spacing)
- Server name in forcedHosts doesn’t exist in servers section
- Player connecting via IP address instead of domain
Load balancing not working
Load balancing not working
Problem: All players go to same server despite multiple listedExplanation: This is expected - Gate uses sequential failover, not random distributionSolution: For true load balancing, use Gate Lite mode with load balancing strategies:
IP connections bypass forced hosts
IP connections bypass forced hosts
Problem: Players connecting via IP address don’t get routedExplanation: This is expected - ForcedHosts only work with domain namesSolutions:
- Encourage players to use domain names
- Configure try list as your “default” routing
- Block IP connections: set
server-ip=127.0.0.1on Gate bind
Forced host server not found
Forced host server not found
Error:
Forced host "creative.example.com" server "creative" must be registered under serversSolution: Add server to servers section:Fallback not working
Fallback not working
Problem: Players get disconnected when hostname doesn’t matchDiagnosis:
- Check try list is configured with available servers
- Verify servers in try list exist in servers section
- Check if servers in try list are actually online
Migration from Broken Configs
If you configured ForcedHosts before it was fixed (PR #560), your configuration should now work automatically! The fix included proper hostname extraction, case normalization, and fallback behavior.
forcedHosts configurations will work after updating Gate.
Comparison: ForcedHosts vs Gate Lite
| Feature | ForcedHosts (Classic) | Gate Lite |
|---|---|---|
| Hostname-based routing | ✅ | ✅ |
| Sequential failover | ✅ | ✅ |
| Random load balancing | ❌ | ✅ |
| Round-robin | ❌ | ✅ |
| Least-connections | ❌ | ✅ |
| Lowest-latency | ❌ | ✅ |
| Wildcard hostnames | ❌ | ✅ |
| Hostname regex | ❌ | ✅ (patterns) |
| Server switching | ✅ (/server command) | ❌ (thin proxy) |
| Proxy commands | ✅ | ❌ |
| Extensions/plugins | ✅ (full access) | ⚠️ (limited) |
| Performance | Good | Excellent (lower latency) |
Best Practices
Use descriptive hostnames
Use descriptive hostnames
Choose clear, memorable hostnames:
- ✅
creative.example.com,survival.example.com - ❌
s1.example.com,server2.example.com
Configure a solid try list
Configure a solid try list
Always have reliable fallback servers in try list for unmatched hostnames or IP connections:
Document your routing
Document your routing
Keep documentation of which domains route where. Add comments:
Test all hostnames
Test all hostnames
After configuration changes, test each hostname:
Use wildcard DNS carefully
Use wildcard DNS carefully
If using wildcard DNS (
*.example.com), remember all subdomains will resolve. Consider:- Adding explicit forcedHosts for intended subdomains
- Having good default try list for unmatched subdomains
Related Configuration
Servers
Configure backend servers and try list
Gate Lite Mode
Advanced host-based routing with load balancing
Forwarding
Forward player info to backend servers
Status Ping
Customize server list appearance per hostname

