sup*_*way 6 python reverse-proxy centos nginx apache-superset
我在使用 Nginx 作为反向代理设置 apache superset 时遇到问题(这可能是 nginx 配置错误)。
服务器配置块(如果我缺少某些内容,请告诉我,我会添加它):
server {
listen 80 default_server;
server_name _;
root /var/www/data;
error_log /var/www/bokehapps/log/nginx.error.log info;
location /static {
alias /usr/lib/python2.7/site-packages/bokeh/server/static;
}
location /superset {
proxy_pass http://0.0.0.0:8088;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
}
}
Run Code Online (Sandbox Code Playgroud)
我能够进入 0.0.0.0:8088 以获得重定向页面,并且我的请求正在将其发送到 werkzeug。但在我的浏览器中,一切都是 404。
由于您在前缀位置 ( /superset) 上提供服务,并且即使您是传递到 的代理/,werkzeug 也会尝试提供/superset不存在的路线,因此为 404。
你应该定义一个前缀中间件,可以在这个线程中找到一个非常好的解释:Add a prefix to all Flask paths。
中间件应该作为相关文档的一部分传递给 Superset superset-config.py/ FAB
将两者结合起来,您可能最终会在您的superset-config.py:
class PrefixMiddleware(object):
def __init__(self, app, prefix='superset'):
self.app = app
self.prefix = prefix
def __call__(self, environ, start_response):
if environ['PATH_INFO'].startswith(self.prefix):
environ['PATH_INFO'] = environ['PATH_INFO'][len(self.prefix):]
environ['SCRIPT_NAME'] = self.prefix
return self.app(environ, start_response)
else:
start_response('404', [('Content-Type', 'text/plain')])
return ["This url does not belong to the app.".encode()]
ADDITIONAL_MIDDLEWARE = [PrefixMiddleware, ]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11376 次 |
| 最近记录: |