尝试将气流设置为在反向代理后面运行,如下所述: https://airflow.readthedocs.io/en/stable/howto/run-behind-proxy.html
我正在运行airflow v1.10.3并启用了ProxyFix:
[webserver]
enable_proxy_fix = True
已在Web服务器日志中确认它已正确启动:
^{pr2}$然后运行以下命令:
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
头而不是{
你知道我缺少什么配置吗?在
找到了根本原因,这与不同的werkzeug版本有关(我运行的是0.15.x而不是0.14.x)。在
https://werkzeug.palletsprojects.com/en/0.14.x/contrib/fixers/https://werkzeug.palletsprojects.com/en/0.15.x/middleware/proxy_fix/#module-werkzeug.middleware.proxy_fix
默认情况下,
0.15.x
版本需要设置x_host=1
,以便信任第一个X-Forwarded-Host
头,否则ProxyFix将完全忽略该头。Airflow不提供现成的钩子来设置此属性,因此Airflow的ProxyFix不能与werkzeug0.15.x
一起使用。在0.14.x
默认情况下信任第一个标头,但它与flask>;=1.10不兼容,后者气流使用:https://issues.apache.org/jira/browse/AIRFLOW-4900
这已在气流1.10.4中固定: https://github.com/apache/airflow/pull/5563
相关问题 更多 >
编程相关推荐