節點。js作為應用程序容器

[英]Node.js as an application container


Apache and Node.js have something in common. The more I use Node.js, the more I like Node.js; similarly, more I use Apache, the more I like Node.js.

Apache和節點。js有一些共同點。使用Node的次數越多。js,我更喜歡Node.js;類似地,我使用Apache越多,我就越喜歡Node.js。

One good thing about Apache though, it can do a lot of things through the same port. PHP, Python, Perl, different apps, different paths, the whole magilla. Node.js doesn't do that, and it isn't supposed to but I would like to do something similar.

Apache的一個優點是,它可以通過同一個端口做很多事情。PHP, Python, Perl,不同的應用程序,不同的路徑,整個馬尼拉。節點。js不這么做,也不應該這么做,但我想做一些類似的事情。

I would like to give it a list of URL-prefixes (or regexps ideally) and enough information to, if it receives a request matching a particular prefix, it passes off the request to a subordinate instance running a specified script (and it will start such an instance if it hasn't already, and close it down when doing so seems prudent). Basically, I want nodejs-proxy and cluster cooperating. With it, I could run several apps together on the same machine through port 80.

我想給它一個url前綴列表(或regexp理想)和足夠的信息,如果它收到一個請求匹配一個特定的前綴,它將從請求傳遞給下屬實例運行指定的腳本(它會啟動這樣一個實例如果還沒有准備好,並關閉它下來,這樣做似乎謹慎)。基本上,我希望節點代理和集群協作。有了它,我可以通過端口80在同一台機器上運行幾個應用程序。

This seems pretty easy and very useful and I was about to just write it myself when it occurred to me, "This seems pretty easy and very useful -- probably someone has already written it!" Any suggestions?

這看起來很簡單也很有用,我正要自己寫出來,突然想到:“這看起來很簡單也很有用——可能有人已經寫過了!”有什么建議嗎?

4 个解决方案

#1


7  

Node.js doesn’t have any built-in ability to route requests to different applications, but frameworks like this are in development.

節點。js沒有任何將請求路由到不同應用程序的內置功能,但是像這樣的框架正在開發中。

Nodejitsu’s Haibu comes to mind — it manages child processes for each application and uses node-http-proxy to route the requests.

Nodejitsu的Haibu想到了—它為每個應用程序管理子進程,並使用node-http-proxy來路由請求。

#2


1  

You could take a look at http://expressjs.com which I describe as a 'sinatra for node'. It gives the whole URL/pattern based routing thing. You can couple this with https://github.com/visionmedia/express-resource to create a kinda RESTful style resource approach.

您可以查看http://expressjs.com,我把它描述為“node的sinatra”。它提供了基於URL/模式的路由選擇。您可以將其與https://github.com/visionmedia/express-resource結合,以創建某種RESTful風格的資源方法。

#3


0  

To me it sounds like you're looking for an event-based HTTP proxy (to replace Apache) - in that regard, nginx seem to be current king of the hill.

對我來說,這聽起來像是你在尋找一個基於事件的HTTP代理(以取代Apache)——在這方面,nginx似乎是當前的山之王。

#4


0  

Use dokku (Docker based) which will spawn your apps and provide a reverse proxy via nginx. Containers are isolated, you have a choice of buildpacks and your deployments have 0 downtime all by pushing repos via git and auth via ssh.

使用dokku(基於Docker)生成應用程序並通過nginx提供反向代理。容器是獨立的,您可以選擇構建步驟,並且您的部署通過通過git和ssh來推動repos,從而使您的部署有0停機時間。

You can follow this easy guide on DigitalOcean on how to deploy your Node.js apps or just watch the guide from the man himself.

您可以按照這個簡單的指南在DigitalOcean中了解如何部署節點。js應用程序,或者只看這個人自己的指南。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/08/29/720816c1f27085fcd0cd10b37ebd6a4.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com