【发布时间】:2020-08-13 12:14:44
【问题描述】:
我有 Ubuntu 18.04 和 Apache 2.4.29 的 VPS。当我运行npm run start 时,一切正常如果我通过http://example.com 访问我的页面。
我安装了 Let's Encrypt 证书,在 nuxt.config.js 中启用了 https,所以现在 nuxt 正在监听 https://example.com。
我在 Apache 的 sites-available 文件夹中的 example.com-le-ssl.conf 如下所示:
<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
【问题讨论】:
标签: ubuntu apache2 nuxt.js vps lets-encrypt