【发布时间】:2019-08-16 21:57:36
【问题描述】:
尝试设置气流以在反向代理后面运行,如下所述: https://airflow.readthedocs.io/en/stable/howto/run-behind-proxy.html
我正在运行气流 v1.10.3 并启用了 ProxyFix:
[webserver]
enable_proxy_fix = True
在网络服务器日志中确认它已正确启动:
/usr/local/lib/python3.6/site-packages/airflow/www_rbac/app.py:48: DeprecationWarning: 'werkzeug.contrib.fixers.ProxyFix' has moved to 'werkzeug.middleware.proxy_fix.ProxyFix'. This import is deprecated as of version 0.15 and will be removed in 1.0.
然后运行以下内容:
curl http://localhost:8080 --header "X-Forwarded-Host: airflow.staging.spothero.com" -v
* Rebuilt URL to: http://localhost:8080/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
> X-Forwarded-Host: airflow.staging.spothero.com
>
< HTTP/1.1 302 FOUND
< Server: gunicorn/19.9.0
< Date: Fri, 16 Aug 2019 17:14:54 GMT
< Connection: close
< Content-Type: text/html; charset=utf-8
< Content-Length: 217
< Location: http://localhost:8080/home```
curl http://localhost:8080 --header "Host: airflow.staging.spothero.com" -v
* Rebuilt URL to: http://localhost:8080/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET / HTTP/1.1
> Host: airflow.staging.spothero.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 302 FOUND
< Server: gunicorn/19.9.0
< Date: Fri, 16 Aug 2019 17:21:27 GMT
< Connection: close
< Content-Type: text/html; charset=utf-8
< Content-Length: 217
< Location: http://airflow.staging.spothero.com/home
您可以看到使用Host 标头正确生成重定向,但使用X-Forwarded-Host 标头错误生成。 ProxyFix 应该在生成这些重定向时使用 X-Forwarded-Host 标头而不是 Host 标头,但由于某种原因它不是。
关于我在这里缺少什么配置的任何想法?
【问题讨论】:
标签: python proxy reverse-proxy airflow werkzeug