简体   繁体   English

在Apache Proxy后面运行多个Node.js服务器

[英]Running multiple Node.js Servers behind Apache Proxy

I'm running multiple Node.js Server on different ports and using Websocket in my client to connect with these different servers. 我在不同的端口上运行多个Node.js服务器,并在我的客户端使用Websocket连接这些不同的服务器。 Clients are making Ajax calls without websocket also using given server ports and everything is working fine. 客户端正在使用给定的服务器端口进行没有websocket的Ajax调用,一切正常。

Now the problem is that because I'm using nonstandard ports to run multiple node.js server so while making calls from client side, they are being blocked by firewall. 现在的问题是,因为我使用非标准端口来运行多个node.js服务器,所以在从客户端进行调用时,它们被防火墙阻止。 So I want to introduce an Apache proxy in between and send all the retests to apache on standard port 80 and then interact with multiple Node.js servers in the background. 所以我想在它们之间引入一个Apache代理,并在标准端口80上将所有重新测试发送到apache,然后在后台与多个Node.js服务器进行交互。 I tried to explain existing and desired senario in attached file. 我试图在附件中解释现有和期望的senario。

Need your help to have appropriate Apache proxy configuration to make it work. 需要您的帮助才能使其具有适当的Apache代理配置。 在此输入图像描述

You can probably try with virtual host and proxy pass eg 您可以尝试使用虚拟主机和代理传递,例如

    <VirtualHost *:80>
        ProxyRequests off
        <Proxy *>
                Order deny,allow
                #Require all granted
                Allow from all
        </Proxy>

        ProxyPass /A?query http://example.com/app
        ProxyPassReverse /A?query http://example.com/app

        ProxyPass /B?query http://localhost:8081/$1
        ProxyPassReverse/B?query http://localhost:8081/$1

        ProxyPassMatch "^(/.{1,})$" http://localhost:8082/$1
        ProxyPassReverse "^(/.{1,})$" http://localhost:8082/$1

  </VirtualHost>

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

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