Apache2服务器和Superset,502代理错误,加载仪表板时从远程服务器读取错误



简介

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

问题

对Apache Dremio数据引擎的请求可能需要一些时间(<60秒(。当访问Superset上的仪表板时,使用带SSL的DNS名称和代理设置,某些仪表板部件(请求(失败,并出现以下错误:

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. ProxyPass的Keepalive=On
  4. 不同的SetEnv
  5. superset_config.py->ENABLE_PROXY_FIX,SUPERSET_WEBSERVER_TIMEOUT

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

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

有用信息

Apache Superset版本:0.37.2

Apache Dremio版本:4.1.0

Apache2服务器版本:2.4.29

EC2实例类型:t3.介质

操作系统版本:Ubuntu 18.04

问题出在终止gunicornasync工作程序中。来自图表的请求太多了,工作人员无法处理这些请求。将工作程序类型从async更改为sync(默认的gunicorn类型(解决了代理问题。

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

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

p.S从Apache Superset的文档中推荐的工作者类型是async,但就我的情况而言,sync是更好的解决方案。理论上,同步工作程序比异步工作程序慢(在Superset上下文中(。

下面是这篇详细的文章: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). 

由于默认的保活设置是2秒,因此它在IP直接访问时运行良好。

最新更新