I have a game server on Centos 6.3 which has a single static IP, but hosts 3 different games, each on a different port. Port
4000 is the game's default query port and I host instances on subsequent ports.
At the moment, players have to connect to each game by typing an IP/hostname and a port, like so:
server1.mygame.com:4001for game 1
server2.mygame.com:4002for game 2
server3.mygame.com:4003for game 3
What I'd like to do is make it so that players don't need to type the ports, and only have to remember the hostnames:
server1.mygame.comfor game 1
server2.mygame.comfor game 2
server3.mygame.comfor game 3
I understand that this (port redirection/forwarding) isn't possible using only DNS A-Records or whatever. So I set up Apache to listen on the default query port for the game, and used name-based virtual hosts to attempt to 301 Redirect connections to their appropriate ports. E.g. a vhost name matching
server1.mygame.com was 301'd to port 4001.
This worked in the browser - I saw the redirects working fine! But sadly it didn't work in the game. My guess is the game can't follow 301 redirects. I also tried a reverse-proxy through Apache but this also failed.
So I'm wondering if there's any way to set up name-based port forwarding without using Apache.
Basically I need these rules put into place somehow:
Connection to 123.123.123 established on port 4000 (query port). If the hostname is "server1.mygame.com" --> forward to 4001. If the hostname is "server2.mygame.com" --> forward to 4002. If the hostname is "server3.mygame.com" --> forward to 4003.
All without Apache or 301 redirects.
Is this possible?