簡體   English   中英

如何在沒有Apache端口的情況下讓Node.js運行在Apache服務器上

[英]How do I get nodejs to run without a port number on a Apache server

我有一個在codeigniter環境中運行的nodejs api應用程序。 我試圖在不使用URL中的端口號的情況下訪問nodejs api

目前,您只能在以下位置點擊節點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

有關更多魔術,請參見ProxyPassProxyPassReverse

免責聲明:我沒有使用Codeigniter的經驗,因此這可能不相關或錯誤。

您的node.js服務器監聽端口8010,這是非標准端口,因此您需要在URL中進行指示。

您似乎暗示codeigniter已在偵聽標准端口(80)。 我不了解codeigniter的情況下所看到的解決該問題的方法是,將所有node.js url托管在codeigniter中,然后將它們重定向到端口8010:

Client call /node on port 80
CodeIgniter call /node on himself at port 8010
Node get the request and answer
Code igniter gove the answer to the client

或相反,這將是在node.js中托管任何codeigniter URL,並將它們重定向到codeigniter將偵聽的任何端口。

否則,您將需要配置Apache以將請求重定向到端口或8010上的任何代碼點火器,具體取決於URL。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM