简体   繁体   English

端口80上的Apache和Node

[英]Apache and Node on port 80

**I have seen a similiar question here, with no proper answer **我在这里看到了类似的问题,没有正确的答案

I want both Apache and Node.js to run on port 80, so that it won't be necessary to type port number at the address bar. 我希望Apache和Node.js都在端口80上运行,这样就不必在地址栏中键入端口号。 But my Node.js app won't work when I listen on port 80 instead of 3000, I guess that's because Apache is already on 80. 但是,当我在端口80而不是3000上侦听时,我的Node.js应用程序将无法运行,我想那是因为Apache已经在80上了。

Or, the solution requires to actually use other port than 80 and somehow hide it? 或者,该解决方案要求实际使用80以外的其他端口并以某种方式隐藏它?

In TCP, you can only run 1 service per port . 在TCP中, 每个端口只能运行1个服务 As soon the port is assigned to a service, it becomes unavailable to anybody else. 将端口分配给服务后,其他任何人都将无法使用该端口。

However there is a way to share port betwen NODE and APACHE, proxying the connections using an Apache 2 Module (mod_proxy and mod_proxy_http) . 但是,有一种方法可以共享NODE和APACHE之间的端口,并使用Apache 2模块(mod_proxy和mod_proxy_http) 代理连接 You can get more details here: how to put nodejs and apache in the same port 80 您可以在此处获得更多详细信息: 如何将nodejs和apache放在同一端口80

Apache configuration example to use Apache in requests to http://example.com/ and Node.js for requests to http://example.com/node/ : Apache的配置示例使用Apache的请求http://example.com/和Node.js的用于请求http://example.com/node/

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/example/
    <Location /node>
        ProxyPass http://127.0.0.1:8124/
        ProxyPassReverse http://127.0.0.1:8124/
    </Location>
</VirtualHost>

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

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