【问题标题】:Apache2 server and Superset, 502 Proxy Error, error reading from remote server while dashboards loadingApache2 服务器和 Superset,502 代理错误,在加载仪表板时从远程服务器读取错误
【发布时间】:2021-02-17 15:19:57
【问题描述】:

简介

我的 Apache Superset 和 Apache2 服务器位于同一个 EC2 实例上。 Apache2 充当代理服务器。它接受 HTTPS 请求并将它们传输到 Apache Superset。 Apache Superset 使用 gunicorn 运行。

问题

对 Apache Dremio 数据引擎的请求可能需要一些时间(

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

奇怪的是,尽管ProxyTimeout 的默认值相当高,但这些错误可能会在几秒钟内出现。

如果通过IP地址访问Superset,则不会出现此问题。

apache2/error.log 中的错误消息:

(20014) Internal error (specific information not available): [client 10.4.26.3:6969] AH01102: error reading status line from remote server localhost:8088, referer: ...

解决问题的方法

问题可能与代理服务器超时或 Superset Web 服务器断开一些连接有关。我的 Apache2 配置:

<VirtualHost *:443>
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName dash.domain.com
  ServerAlias dash.domain.com

  SSLEngine on
  SSLCertificateFile /etc/ssl/private/cert.crt
  SSLCertificateChainFile /etc/ssl/certs/cert2.crt
  SSLCertificateKeyFile /etc/ssl/private/key.key

  ProxyPass / http://localhost:8088/ connectiontimeout=3600 timeout=3600
  ProxyPassReverse / http://localhost:8088/

  # things tried
  # SetEnv force-proxy-request-1.0 1
  # SetEnv proxy-nokeepalive 1
  # SetEnv proxy-initial-not-pooled 1
  # ProxyTimeout 3600
  # TimeOut 3600
</VirtualHost>

经过测试(但不工作):

  1. TimeoutProxyTimeout
  2. connectiontimeouttimeout(如上所示)
  3. Keepalive=On 用于 ProxyPass
  4. 不同的SetEnv
  5. superset_config.py -> ENABLE_PROXY_FIX,SUPERSET_WEBSERVER_TIMEOUT

此外,使用nginx 构建了类似的代理设置,错误与此处描述的类似。

任何帮助或想法将不胜感激。非常感谢!

有用的信息

Apache 超集版本:0.37.2

Apache Dremio 版本:4.1.0

Apache2服务器版本:2.4.29

EC2 实例类型:t3.medium

操作系统版本:Ubuntu 18.04

【问题讨论】:

  • 您的 DNS 设置是什么?
  • DNS 工作正常。我不知道您所说的“DNS 设置”是什么意思。
  • "如果 Superset 通过 IP 地址访问,则不会出现此问题。"鉴于 Nginx 也出现同样的问题,DNS 可能无法正常工作。
  • 但是我仍然可以访问仪表板并且它们正在部分工作。通过IP地址访问时,我没有使用Apache Proxy,而是直接使用Superset。

标签: amazon-ec2 proxy apache2 apache-superset dremio


【解决方案1】:

问题在于即将死去的 gunicorn async 工人。来自图表的请求太多,工作人员无法处理它们。将工作器类型从异步更改为 sync(默认 gunicorn 类型)解决了代理问题。

我仍然不知道为什么通过 IP 直接访问没有产生 502 代理错误。

抱歉,问题中没有包含有关 gunicorn 的信息。

PS 从他们的文档中推荐的 Apache Superset 工作人员类型是 async,但就我而言,sync 是更好的解决方案。理论上,同步工作线程比异步工作慢(在 Superset 上下文中)。

【讨论】:

    【解决方案2】:

    关注这篇详细文章:https://www.tessian.com/blog/how-to-fix-http-502-errors/

    我们已经尝试了建议的修复(基于 AWS ALB 默认连接空闲超时 = 60s 设置):

    Gunicorn (Python)
    As command line arguments:
    
    --keep-alive 65
    

    像魅力一样工作!

    要解释“为什么通过 IP 直接访问不会产生 502 代理错误”,请查看此 Gunicorn 设置文档: https://docs.gunicorn.org/en/stable/settings.html#keepalive

    Generally set in the 1-5 seconds range for servers with direct connection to the client (e.g. when you don’t have separate load balancer). 
    

    由于默认的keepalive设置是2秒,所以在IP直接访问时效果很好。

    【讨论】:

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