1

I've been wondering if it's possible to host multiple applications using a single port on one IP address. I'm meaning a similar method to Apache Virtual Hosts where you can assign domains/subdomains to specific directories, though I'd like to do this where I can host several applications using one port but have a subdomain which determines which application you are connecting to.

An example of how this would work in my head is:

app_server.exe (Instance 1): 111.111.111.111:9999
app_server.exe (Instance 2): 111.111.111.111:9999

Then if I connect to app1.example.com it connects to Instance 1, whereas app2.example.com would connect to Instance 2.

I have no idea whether this is actually possible or not, but I have look and I have no clue as to what it would even be called, so this is my best bet.

2
  • Only if the protocol supports it. Aug 26, 2015 at 23:59
  • 1
    Can you please elaborate upon that @MichaelHampton?
    – Jordan
    Aug 27, 2015 at 0:00

1 Answer 1

1

Yes, this can be done, as long as the application-level protocol in use knows which name was connected to. HTTP knows this, because of the Host: header. TLS knows this (now), because of the "Server Name Indication" extension. I believe FTP can know this, based on some protocol extension, but if you're still using FTP, you are doomed.

If the protocol doesn't have the ability to indicate which name was used, then you can't do this, because all the server knows when a connection is made is the source and destination IP/port are involved. Everything else needs to passed at a higher level.

One point as to your proposed implementation: you'll need to have a single service listening on the port which receives the connections, parses the incoming data sufficiently to be able to determine which name was requested, and then (and only then) can it route the request to different instances of the application for processing. If those instances are separate processes, then some means of communicating the request to the backend which will handle it (such as proxying, or, if you're dealing with a really good protocol design, socket handoff), but if you implement the various handlers in the same process (say, with configuration or dynamically loadable modules) then you can just create a data structure with the request in it and pass it off to whatever wants to deal with it.

8
  • Okay, so if I am running several game servers this may work, or not? Where would I begin/what software is there that I can experiment with?
    – Jordan
    Aug 27, 2015 at 0:08
  • It almost certainly won't work; game server protocols are notoriously hideous. I don't know what to suggest for "experimentation", because I don't know what you want to experiment with.
    – womble
    Aug 27, 2015 at 0:10
  • Well essentially, I would like to run multiple game servers that "ignore" the fact that there is any other game servers running on that port. From then on, one you connect to app1.example.com it will point towards that file ("app_server.exe"), I'm not really entirely sure on how else to describe it. :p
    – Jordan
    Aug 27, 2015 at 0:18
  • Well essentially, the protocol needs to support that.
    – womble
    Aug 27, 2015 at 1:08
  • Right, so can this connection management be done with a high level language like PHP or do I need to get deeper than that?
    – Jordan
    Aug 28, 2015 at 18:02

You must log in to answer this question.

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