Saturday, January 29, 2011

How to create a shortcut for a IP:port url ?

I have a service running on a specific port on a given ip : 12.34.56.78:12345. The server at this IP address is all mine (but not the network, so no switch/router tweaking), and I also have a bunch of domains and DNS server I could use.

Is there a way to build a "shortcut" for this IP:port adress that would be easier for users to remember ? The IP part is not the problem (I can use the domain instead) but the port is.

Ideally, something like a mappting service.mydomain.com => 12.34.56.78:12345 would be perfect, but this is AFAIK not possible.

EDIT: as it seems this was unclear, my question is not targeted to HTTP traffic, but for a TeamSpeak server. Thus, users need to enter 12.34.56.78:12345 in their client when setting things up, and I was wondering if there was a way to make this easier.

  • Your "impossible" assumption is right in the context of protocols that use hostnames and not URLs.

    A hostname is just a mapping of name to IP address. No application-layer information (TCP ports, etc) is conveyed in a hostname. You're conflating the URL syntax of "protocol://hostname:port" with just hostnames that non-URL-based protocols use.

    SRV records are supposed to solve this kind of problem, but very few protocols use SRV RR's to resolve the protocol endpoints. (Which is a shame, really...)

    In the context of a the HTTP protocol, you could used a name-based virtual host to do what you're talking about, but then your "port 12345" wouldn't be needed anyway, since name-based virtual hosts exist for the purpose of allowing you to run multiple web server instances on a single IP address and TCP port (typically the well-known HTTP port, 80).

    Wookai : Thanks for your detailed answer. Unfortunately, the service I was thinking about is a Teamspeak server. Instead of telling users to connect on `mydomain.com:14534`, I'd better tell them `ts.mydomain.com`. But it's not that important...
    Evan Anderson : I'm not familiar with TeamSpeak. From what I'm reading, I'm unclear if you're talking about something the user is going to put in their browser, or if you're talking about the server they specify in the TeamSpeak client.
    Wookai : Sorry if I was not clear. I'm talking about the server address they will put in their client.
  • Could you run a "bookmarks" webpage somewhere that has a clickable link with the full Hostname/Port in a anchor tag ie: <a href="protocol://hostname:port">My link</a> to make it easier for users? This only works if the browser or the OS shell has a handler for that URI protocol. (There are instructions online on how to create protocol handlers in Windows Shell)

    Mark

    Wookai : This may be a nice alternative, yes. Thanks !
    Wookai : Accepted this answer by lack of better solution...
    From mfarver
  • You can use apache's mod_proxy to transparently proxy traffic from a "standard" port 80 URL through to your app listening on :12345.

    Wookai : Could you elaborate on that ? Does this mean I could setup a virtual host to redirect traffic on ts.mydomain.com to mydomain.com:12345 ?
    ErikA : It wouldn't be a redirect, but rather a true proxy. You'd set up a vhost in apache (say http://app.example.com) with mod_proxy enabled and configured to proxy traffic through to the "real" URL of the application. Then when someone enters http://app.example.com in their browser, the traffic will go through the apache vhost, to the real app and back along the same path. Just google mod_proxy, there's a ton of documentation out there on it.
    ErikA : Oh, I see your edit now, specifying that this is for TS, not HTTP. In this case, mod_proxy won't help you at all.
    From ErikA

0 comments:

Post a Comment