如何解决使用Apache2的Nuxt返回502代理错误:从远程服务器读取错误
我在Ubuntu 18.04和Apache 2.4.29上都有VPS。运行npm run start
时,如果我通过http://example.com
访问页面,一切正常。
我安装了Let's Encrypt证书,并在https
中启用了nuxt.config.js
,所以现在nuxt正在监听https://example.com
。
我的example.com-le-ssl.conf
在Apache的sites-available
文件夹中看起来像这样:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin email@example.com
DocumentRoot /var/www/example.com
ServerName example.com
ServerAlias www.example.com
SSLEngine On
SSLProxyEngine On
ProxyPreserveHost On
ProxyPass / https://123.123.12.123:3000/
ProxyPassReverse / https://123.123.12.123:3000/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
访问https://example.com
时返回502代理错误:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request
Reason: Error reading from remote server
Apache/2.4.29 (Ubuntu) Server at example.com Port 443
nuxt或其他一些Apache设置是否有问题?还是带证书的东西?但是,如果我不使用端口3000的ProxyPass且我未运行nuxt应用,则https可以工作。因此,https://example.com
可以工作,但是当我尝试在端口3000上启动nuxt并使用ProxyPass来使用后端服务器时就无法使用。
我的error.log文件:
[Thu Aug 13 14:11:12.935753 2020] [proxy:error] [pid 22355:tid 140240589145856] [client 87.197.115.218:63122] AH00898: Error reading from remote server returned by /
[Thu Aug 13 14:11:13.009134 2020] [proxy_http:error] [pid 22355:tid 140240580753152] (103)Software caused connection abort: [client 87.197.115.218:63122] AH01102: error reading status line from remote server 123.123.12.123:3000
解决方法
问题是我在nuxt.config.js
中启用了https,然后在example.com-le-ssl.conf
中使用了ProxyPass到该https。对我来说,解决方案是在http上启动nuxt,然后在我的example.com-le-ssl.conf
文件中将https更改为http。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。