Friday, January 28, 2011

Jetty8 virtual hosts

I have a server JAR that is deployed once per customer, it is the API server for their software package. To that end, the port for each API instance must be the same, so that anything programmed against it can always find it. Each instance is deployed on a different domain name

The problem I'm having is that, even when using a SelectChannelConnector and setting the host property, I can't get two instances to run simultaneously, I get a BindException with "Address already in use".

I suppose my question is: can Jetty do this, or do I need to do some external re-writing, or is there a better way I can go about achieving the same ends?

Thanks.

  • Assuming that I understand what you are trying to do, it seems the easiest way is to front your jetty instances with apache. Set apache up with virtual hosts and the appropriate configuration to send each virtual host's requests to the appropriate jetty instance.

    Martin : Thanks Allen, this is roughly what I did, but I used Jetty instead, and each API instance tells the Jetty proxy server which port to find it on, and the Jetty proxy forwards the request appropriately.
    From Allen
  • A bit late maybe but, it this what you're looking for? You'll configure a single connector (because you're listening on a single port) but let it answer for different domain names, and then you configure each webapp to answer to only a single domain. You can even make them have the same context path, so the only thing you change in your client code is the domain name.

0 comments:

Post a Comment