端口 Apache 和 ExpressJS
我正在使用 Apache,它监听端口 80、expressjs 和 socket.io。主要是我的问题是我应该让expressjs监听哪个端口,这样我就不需要在url上写端口了。
假设我想获取这个 url 的 id:
localhost/web/:id
问题是,如果我在端口 80 上运行 Apache,那么expressjs 将无法识别该 url,所以我应该这样写[如果我有 app.listen(81 )]:
localhost:81/web/:id
这实际上是不真实的,因为我无法让用户写:81 我读过一些有关 http-node-proxy 的内容,但不太理解,
谢谢!
I am using Apache, which listens on port 80, expressjs and socket.io. Mainly, my question is in which port should I make expressjs to listen to so that I do not need to write the port on the url.
Let's say I want to get the id of this url:
localhost/web/:id
The problem is that if I have Apache running on port 80, then expressjs won't recognize that url, so I should write it like this [if I have app.listen(81)]:
localhost:81/web/:id
Which is actually unreal because I can't make the user to write :81
I've read something about http-node-proxy, but don't understand pretty well
Thanks!
为什么需要同时运行 Apache 和 Node?
如果有要求,您将需要想出一种方法将特定路由/路径转发到您托管资源的特定服务器。这称为反向 http 代理。
您可以:
或者...崩溃你的服务器并只需使用节点。 Node 可以进行静态文件托管(不是很好,但这都是相对的)
Why do you need to run both Apache and Node?
If its a requirement, you're going to need to come up with a way to forward a particular route/path on to the particular server you're hosting resources on. This is called a reverse http proxy.
You can:
Or... collapse your servers and just use node. Node can do static file hosting (not super well, but that's all relative)