I have a personall machine running Ubuntu 14.04.4 LTS. I use it to host a Teamspeak and a Minecraft server and also a website.

I am trying to make sub-domains to only point to the right services. So for example

using panel.example.com would point only to https://localhost:8000 (CP Panel) Managed to get the CP Panel sorted out, by using a DNS URL Redirect rather than an A Record

using mc.example.com would point only to localhost:25565 (Minecraft Server)

using ts.example.com would point only to localhost:9987 (Teamspeak Server)

using example.com would point only to the website (example.com/forums /index.php)

I managed to do this atleast for connections that come trough a web browser using this httpd.conf:

<VirtualHost *:80>
ServerName mc.example.com
redirect / localhost:25565

<VirtualHost *:80>
ServerName ts.example.com
redirect / localhost:9987

But this only applies to connections coming from a web browser, and if i try to connect in Teamspeak using any sub-domain or the domain name it still connects...

This is probably useless, and i should just use the domain name, but i would like to have some sorting going on.

Is this even possible to do?

From what I can figure out it would be something to do with IPTables but I honestly have no clue. Something like this?

iptables coming from any ip:25565 to anything else than localhost:25565 Drop
iptables coming from any ip:9987 to anything else than localhost:9987 Drop
iptables coming from any ip:80 to anything else than localhost:80/8000 Drop

Am I correct?

1 Answer 1


The IPTABLE rules you created will reject all the traffic, remove them. Those apache rules are useless as well.
I think the only way to do what you want is to add 3 virtual network adapters to your Linux server, then each adapter would have a valid external IP address. You would configure the DNS to point each domain name to point to one of the 4 IP addresses.

Minecraft should bind to the externalIp1:25565, Teamspeak bind to externalIP2:9987, CPannel binding to externalIP3, and finally, Apache on externalIP4:80.

When I say "binding" I mean that the application must be configure to listen in a specific IP, instead of ANY IP (which is the default behaviour of the majority of applications).

  • How would i make the DNS point directly to apache? I am using a free domain provider and they do not let me put it ports to the target box. Image - >i.imgur.com/3LwaP0w.png
    – SteelShot
    Commented Jun 12, 2016 at 19:44
  • @SteelShot, on DNS you won't specify any port, on DNS your specify that ts.domain.com, mc.domain, etc will point to the APACHE server IP address. The clients must connect to ts.domain.com, mc.domain.com, etc. If clients use those urls, they'll connect to APACHE on port 80. Commented Jun 12, 2016 at 20:32
  • I still dont fully understand, what is the APACHE ip? All the sub-domains + domain are pointing to my server's external IP, i dont have any other IP's available to my knowledge. I've tried using what you've given me, ProxyPass is requesting an absolute URL, but Minecraft and Teamspeak are not website based services, also after this panel.domain.com gives me an Internal Server Error
    – SteelShot
    Commented Jun 12, 2016 at 21:07
  • I guess your apache is on the same machine that Teamspeak and Minecraft right? If yes, your DNS is configured properly. But are you saying that Teamspeak and Minecraft don't work on http protocol? If they don't use http protocol Apache won't work for your problem. Commented Jun 13, 2016 at 2:04
  • It wont work, I am hosting this at home, so i'm bound to 1 IP, the only thing i do i can make the server have as you said 4 different IP's but they would have to be 192.168.1.xxx, atm its just .200 and then there would be some form of a hybrib apache like routing going on(not only on http, but on all connections), ill just stick with what I have. I changed the panel only to redirect to a URL, so that doenst work anymore in Minecraft and Teamspeak clients The IPtables rules, havent even touched them in the first place, just was generally asking if that was the way to go.
    – SteelShot
    Commented Jun 13, 2016 at 10:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .