【问题标题】:Nuxt with Apache2 returns 502 Proxy Error: Error reading from remote serverNuxt 与 Apache2 返回 502 代理错误:从远程服务器读取错误
【发布时间】: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


    【解决方案1】:

    问题是我在nuxt.config.js 中启用了https,然后在example.com-le-ssl.conf 中使用了该https 的ProxyPass。我的解决方案是在 http 上启动 nuxt,并在我的 example.com-le-ssl.conf 文件中将 https 更改为 http。

    【讨论】:

      猜你喜欢
      • 2017-01-13
      • 1970-01-01
      • 1970-01-01
      • 2021-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多