-3

How can I create a domain mysql1.domain.com in Windows Server 2008 R2 and set the server to connect the local MySQL server on port 3306 when someone uses that domain in his application? How about then if I want that only the users in the same network (connected via VPN) can access an another MySQL server by typing in mysql2.domain.com?

  • 1
    What on earth are you trying to do? This doesn't make any sense. – MDMarra Jul 02 '12 at 13:40
  • I want to give users an ability to connect different programs by using program.domain.com instead of domain.com:port. – user14085 Jul 02 '12 at 13:54
  • 1
    Port numbers are not included in A or CNAME records in DNS. There's no way for you to specify a port number unless the client program understands SVR records (which is annoyingly rare). See the related: http://serverfault.com/questions/74362/how-to-use-dns-to-redirect-domain-to-specific-port-on-my-server – Chris S Jul 02 '12 at 14:02

1 Answers1

4

Every network-enabled service needs a port. Even HTTP/HTTPS does, but the browser typically hides :80 and :443 from the user's view since they're nice like that. It doesn't change the fact that they're still used. You can't just have a network-enabled service like MySQL not use a port.

I think you may be getting confused, because you are able to resolve web sites without specifying a port. In reality, you do specify a port, but your browser appends :80 or :443 as needed. If you had a default port that all traffic was coming in on, you could put a reverse proxy in the middle and redirect traffic to a different port from that, but there's no native baked-in way to just say "meh, I don't want to use ports across the Internet." It's just the way that TCP/IP works.


Edit: Buried in your misguided comments that were deleted by a moderator, you said this:

I want to route traffic on exa.mp.le:80 to another port.

That is completely different than your original question, but it is answerable.

On Windows, there's no native tool to do this. You'll need to put a reverse proxy between exa.mp.le and your clients. Then, have a rule on that proxy that forwards that traffic to a different port of your choosing (iptables and pf can do this, as can mod_proxy and many other modules).

If the server were running Linux, you could just use a simple iptables rule for this. Unfortunately, though much better in 2008 and 2008 R2, Windows Firewall still hasn't reached feature parity with iptables.

MDMarra
  • 100,183
  • 32
  • 195
  • 326
  • 1
    MySQL behind a reverse proxy. LIKE A BOSS. – pauska Jul 02 '12 at 14:31
  • Maybe I wouldn't be here asking this kind of questions if I didn't know how networking works. What I didn't know and what I wanted to learn was how some people has done sites like gameserver1.domain.com and gameserver2.domain.com which aren't websites and only the specific game can connect to that address to reach the gameserver for the game. Ofcourse they can listen to port 80 but that doesn't work if there are multiple servers like I described earlier. – user14085 Jul 02 '12 at 18:21
  • 1
    I literally have no idea what you just said. – MDMarra Jul 02 '12 at 18:29