Can I configure a subdomain to point to a specific port on my server

alecwhardy picture alecwhardy · Oct 30, 2011 · Viewed 100.3k times · Source

I have an old computer which I converted into a minecraft server. I have 2 minecraft servers running simultaneously, one on port 25565 (default) and one on port 25566.

I bought the domain something.com and pointed it to my server. Right now, in the game you type something.com to get into the first server and something.com:25566 to get into the other server.

Is there a way to set one.something.com to point to the first server and two.something.com to point to the second server? I own the (centos) server, have root access, and everything else. The domain is controlled by no-ip if that makes a difference. I know that DNS has no relationship to port numbers but if there a program I can install to make this work?

Thanks :)

Answer

MRVDOG picture MRVDOG · Oct 5, 2013

If you have access to SRV Records, you can use them to get what you want :)

E.G

A Records

Name: mc1.domain.com
Value: <yourIP>

Name: mc2.domain.com
Value: <yourIP>

SRV Records

Name: _minecraft._tcp.mc1.domain.com
Priority: 5
Weight: 5
Port: 25565
Value: mc1.domain.com

Name: _minecraft._tcp.mc2.domain.com
Priority: 5
Weight: 5
Port: 25566
Value: mc2.domain.com

then in minecraft you can use

mc1.domain.com which will sign you into server 1 using port 25565

and

mc2.domain.com which will sign you into server 2 using port 25566

then on your router you can have it point 25565 and 25566 to the machine with both servers on and Voilà!

Source: This works for me running 2 minecraft servers on the same machine with ports 50500 and 50501