我在 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 上没有任何内容正在侦听。
我不知道还能做什么。有任何想法吗?
你不能
-p
在 PM2 中定义端口,没有这样的选项。也许变量可以完成这项工作(正如您在评论中提到的):