[英]How to run Node And apache together in amazon ec2?
嗨,我在亞馬遜上有一個 ec2 實例,它在正常的 80 端口上運行,我有一個節點在 3002 端口上運行,如何讓我的節點在我的 amazon ec2 實例中的端口 80 上與 apache 一起運行,我嘗試了大多數在線教程,例如反向代理 mod apache上的代理等
我需要在 www.mywebsite.com/node 上運行我的節點服務器,現在它在 www.mywebsite.com:3002/ 上運行
我試圖編輯我的
/etc/httpd/conf/httpd.conf
像下面這樣的 apache 但沒有任何影響
<VirtualHost *:80>
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass /node http://localhost:3002/
ProxyPassReverse /node http://localhost:3002/
</Location>
</VirtualHost>
我已經很久沒有使用 apache 了,但我認為您的 mod_proxy 位置如下所示:
<Location /node >
ProxyPass http://localhost:3002/
</Location>
另外,你有沒有重新啟動apache?
service httpd restart
應該這樣做。
使用 SSH 登錄服務器
轉到httpd.conf文件(“/etc/httpd/conf”)並編輯
sudo nano httpd.conf
在ServerRoot "/etc/httpd" 之后添加這一行ProxyPass /api/ http://localhost:3000/
ServerRoot "/etc/httpd"
ProxyPass /node/ http://localhost:3000/
現在保存httpd.conf文件並在 SSH 中重新啟動 httpd 服務
sudo systemctl restart httpd
現在你在同一台服務器上運行
www.mywebsite.com => Apache
www.mywebsite.com/node => 節點
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.