2

Is it possible to maintain multiple Django (actually, FastCGI/SCGI) projects on one IP address, and distinguish them by port?

I really like Cherokee. Its admin interface and ease of customization, which it brings, are just awesome. So, I feel kinda sad about the lack (at least in an obvious, explicit way) of port-based virtual hosts.

Please, keep in mind while answering:

  1. Match virtual servers by port -- I did read that.

  2. Don't advise other web servers -- I know that I can use them for this purpose, but I'm trying to learn Cherokee better.

Many thanks.

Ewan Doe
  • 205
  • 1
  • 8

1 Answers1

4

Yes, this is possible.

First, you need to set up Cherokee to listen to the desired ports:

Under General -> "Ports to Listen" add the port and leave the IP field blank (for all IPs).

Then, for each application you're hosting, create a virtual host.

For each of the virtual hosts, make sure that all the behaviour rules have an "AND" rule (under the Rules tab) with the "Incoming Port/IP" set to the desired port that you previously set up.

Then the handlers for each rule will only be invoked if the incoming port is matched, exactly as you want.

While testing this out on my own config I ran into some trouble creating an AND rule (upon selection of the "Incoming Port/IP" rule type the config was left in an invalid state until a port was actually chosen), so be sure to backup your configuration file first just in case (mine's at /etc/cherokee/cherokee.conf)!

Cameron
  • 96,106
  • 25
  • 196
  • 225
  • HI Cameron, I am not able to get this to work .. i have "AND"ed all the rules on the new virtual server with the new port rule, but it is still taking me to the document root of the default virtual server, even if accessed using the port. Do i need to change anything in "Host Match" tab ? or am I missing anything ? – Abhay Chaware Mar 14 '12 at 09:33
  • @AbhayChaware: Hmm, I'm not sure. The only thing I can think of is if the default virtual server is above the new virtual server (i.e. is matched first, regardless of whatever rules are in the other vServer). – Cameron Mar 14 '12 at 10:26
  • The new vServer is above the default vServer, but it doesn't work as it is supposed to. If I add a HostMatch / wildcard / domain filter to the new vServer, and access it with that domain name, it works. But not with the port rule. I got it to work in a different fashion though. Here I am not creating any vServers. In the default vServer, I added a rule for "Incoming IP/port" for the new port and then added a "List" handler to point to my new document root. This appears to work fine, unless there is other disadvantage of this approach, that I do not know of as of now.. – Abhay Chaware Mar 15 '12 at 03:50
  • @Abhay: Cool. I guess you lose some flexibility (all vServer conf will apply to every subsite), but that's probably not a big deal. I remember testing the method in my answer, and it was working, but that was quite a while ago! – Cameron Mar 15 '12 at 13:28