用nginx 可以做到..
在你的node外面使用nginx php用php-fpm和nginx通信,利用url规则转发完全满足你的需求。话说回来Apache的反向代理其实也可以,只是不如nginx简单好用速度快。还有在使用反向代理的时候node肯定不是和nginx同一个端口的啦。
<VirtualHost *:80>
ServerName www.test.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>
请注意看这里:
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
是指将/
转发到http://127.0.0.1:9000/
也就是将所有的请求都转到9000
端口了。
试下这样子是否ok。
ProxyPass / http://127.0.0.1:2386/
ProxyPassReverse / http://127.0.0.1:2386/
ProxyPass /wechat/wx.php http://localhost:80/
ProxyPassReverse /wechat/wx.php http://localhost:80/