Apache 無法看到 PM2 節點進程

Apache 無法看到 PM2 節點進程

我在 Ubuntu 20 上運行 Apache,並且不斷收到此錯誤/var/logs/apache2/error.log

[proxy:error] [pid 7064] (111)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:4000 (127.0.0.1) failed

[proxy_http:error] [pid 7064] [client ...] AH01114: HTTP: failed to make connection to backend: 127.0.0.1

我的虛擬主機是這樣設定的:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on

# Reverse Proxy Stuff for Node
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:4000/ Keepalive=On
ProxyPassReverse / http://127.0.0.1:4000/ Keepalive=On

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

在我的網頁目錄 ( /var/www/example.com) 中,我使用 pm2 啟動了我的應用程序,如下所示:

pm2 start index.js -p 4000

當我這樣做時,pm2 status我看到我的流程已在線。中沒有錯誤pm2 logs。不知何故,Apache 和 pm2 沒有相互通信。

netstat -tulpn確認連接埠 4000 上沒有任何內容正在偵聽。

我不知道還能做什麼。有任何想法嗎?

答案1

你不能-p在 PM2 中定義端口,沒有這樣的選項。也許變數可以完成這項工作(正如您在評論中提到的):

port=4000 pm2 start index.js

相關內容