我有一个在 codeigniter 环境中运行的 nodejs api 应用程序。我尝试在不使用 url 中的端口号的情况下访问 nodejs api
目前您只能访问 Node api
http://wrl.xx.com:8010/api
我希望通过如下网址访问它:
http://wrl.xx.com/api/
我尝试运行反向代理但没有成功
<VirtualHost *:80>
ServerName wrl.xx.com
ProxyRequests off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8010/
ProxyPassReverse / http://localhost:8010/
ProxyPreserveHost on
</VirtualHost>
最佳答案
假设您打算通过将 /api
视为根路径来区分查找 Nodejs 应用程序的请求和查找 codigniter 应用程序的请求,请尝试:
ProxyPass /api http://localhost:8010/api
ProxyPassReverse /api http://localhost:8010/api
参见ProxyPass和 ProxyPassReverse为了更多的魔法。
关于javascript - 如何让nodejs在没有端口号的情况下在Apache服务器上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38506977/