views:

92

answers:

3

Hi,

i want to have both an Apache and a Game Server to be reachable on port 443 of the same IP address.

The game server connection is a normal TCP connection that is established when the client logs in and stays open until the client logs out, perhaps hours later.

At first I though about using mod_proxy in reversed mode and let the client start the communication with a request for a specific URL, but I guess that would not allow me a long time two way communications between the client and the game server.

Another idea was to use mod_proxy_connect in forward mode (with strict access rules of course) and let the client send a CONNECT request. In theory this should work.

Both mentioned attempts, however, have a huge issue: The Game Server does not see the ip-address of the client anymore. Unfortunately this is a hard requirement.

Reversing the order has the same issue: If i let the Game server listen on port 443 and forward web request to the Apache, the .php programs and the access.log would not see the real ip-address anymore. And I am a bit afraid that this approach has a negative impact on game performance. (Especially on pages which a huge number of non-cacheable images)

Operating System: Linux (Debian) Webserver: Apache 2 Game Server and client are written in Java

Thank in advance for any ideas.

+1  A: 

You could let Apache create a session id and store it into database and then use mod_proxy_connect. When the Game Server accepts the request from the local Apache, it should get the session id from a header and read the client's ip address from the database.

mhaller
Excellent idea. The game clients requests a .php page using normal HTTP GET which will generate a session-token and write it with timestamp and ip-address to the database. The the client will use CONNECT to connect to the game server and transmit this session-token as part of the (to be extended) game protocol. The extra step is needed because there is no header generated by the Apache in the connection to the game server.Thanks a lot.
nhnb
+1  A: 

How do you run the Game Server? If it's run by Tomcat or Jetty you could try mod_jk

rlovtang
It is not using Tomcat or Jetty. mod_jk / AJP13, however, looks like a nice way to forward the request and its client-ip-address to the server. I am not sure if it is possible to establish a two way communication because GET / POST / PUSH all seem to be designed to client -> server-request, sever->client-answer, finish. But this is approach worth to have a closer look at.
nhnb
+1  A: 

From what you're describing, the game server is not an HTTP(s) server, it just uses port 443 (TCP connection that is established when the client logs in and stays open until the client logs out, perhaps hours later.)

This does not sound like HTTP, even when using keep alive a HTTP connection won't survive more then minutes.

If the game server is not HTTP you can't use an HTTP proxy for its traffic.

diciu
http connections can stay open for hours. That is used by some web based chat pages predating Ajax. But the two way communication is an issue. Those old style chat pages use a second request to send a chatline to the server.
nhnb