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>

私の Web ディレクトリ ( /var/www/example.com) で、次のように pm2 を使用してアプリを起動しました。

pm2 start index.js -p 4000

すると、pm2 statusプロセスがオンラインになっていることがわかります。 にはエラーはありませんpm2 logs。どういうわけか、Apache と pm2 は相互に通信していません。

netstat -tulpnポート 4000 で何もリッスンしていないことを確認します。

他に何をすればいいのか分かりません。何かアイデアはありますか?

答え1

PM2ではポートを定義することはできません-p。そのようなオプションはありません。おそらく変数でその作業を行うことができます (コメントで言及されているように):

port=4000 pm2 start index.js

関連情報