简体   繁体   English

如何将多个Django项目维护为基于端口的Cherokee虚拟主机?

[英]How to maintain multiple Django projects as port-based Cherokee virtual hosts?

Is it possible to maintain multiple Django (actually, FastCGI/SCGI) projects on one IP address, and distinguish them by port? 是否可以在一个IP地址上维护多个Django(实际上是FastCGI / SCGI)项目,并通过端口对其进行区分?

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. 不要建议其他Web服务器-我知道我可以为此目的使用它们,但我正在尝试更好地学习切诺基。

Many thanks. 非常感谢。

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). 在“常规”->“要监听的端口”下,添加端口,并将“ IP”字段留空(对于所有IP)。

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. 对于每个虚拟主机,请确保所有行为规则都具有“与”规则(在“规则”选项卡下),并且“传入端口/ IP”设置为先前设置的所需端口。

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 )! 在自己的配置上进行测试时,我在创建AND规则时遇到了一些麻烦(选择“传入端口/ IP”规则类型时,配置会一直处于无效状态,直到实际选择了端口),因此请确保首先备份您的配置文件,以防万一(我的位于/etc/cherokee/cherokee.conf )!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM