问题描述
问题:我需要承载节点的应用程序,并在不同的域在同一台服务器上的PHP应用程序。
Problem: I need to host a Node-application and a php-application on the same server on different domains.
example.com应该使用80端口正常,但node-example.com路由经过3000端口。
example.com should use port 80 as normal, but node-example.com should route to port 3000.
路由所有流量从80端口3000工作正常使用mod_proxy,正是如此:
Routing ALL traffic from port 80 to 3000 works fine using mod_proxy, thusly:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName node-example.com
ServerAlias www.node-example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>
然而,这使得无论example.com和node-example.com指向到localhost:3000,运行节点应用
This however makes both example.com and node-example.com to point to localhost:3000 and run the Node-app.
有没有办法让example.com指向80端口?
Is there a way to keep example.com to point to port 80?
这也将是没关系example.com/old-admin指向端口80。
It would also be okay for example.com/old-admin to point to port 80.
推荐答案
只要两个&LT;虚拟主机*:80&GT;
标签
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.node-example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName node-example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:80/
ProxyPassReverse http://localhost:80/
</Location>
</VirtualHost>
它应该工作的方式;)
It should work that way ;)
或者,如果你的本地主机:80
应用程序并不节点,可以删除&LT;代理*&GT;
&放; &LT;位置/&GT;
该目标的标签并将其替换为的DocumentRoot /var/www/node-example.com$c$c > - 静态路径的index.html
Or if your localhost:80
app isn't node you can remove <Proxy *>
& <Location />
tags for that target and replace it with DocumentRoot /var/www/node-example.com
- your static path to index.html
这篇关于阿帕奇+ Node.js的+ mod_proxy的。如何路由一个域:3000和另一:80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!