use*_*955 6 apache amazon-web-services airflow elastic-load-balancer
我在EC2上配置了一个气流Web服务器,它在端口8080处侦听。
我在EC2前面有一个AWS ALB(应用程序负载均衡器),在https 80上监听(面向互联网),并且实例目标端口面向http 8080。
我无法从浏览器浏览https:// <airflow link>,因为气流Web服务器将我重定向到http:// <airflow link> / admin,ALB不会监听。
如果我从浏览器浏览https:// <airflow link> / admin / airflow / login?next =%2Fadmin%2F,那么我会看到登录页面,因为此链接不会重定向我。
我的问题是如何更改气流,以便在浏览https:// <airflow link>时,气流Web服务器会将我重定向到https:...,而不是http:// .....,以便AWS ALB可以处理请求。
根据下面的答案,我试图将airflow.cfg的base_url从http:// localhost:8080更改为https:// localhost:8080,但是我看不到任何改变....
无论如何,如何从ALB访问https:// <气流链接>?
由于他们使用 Gunicorn - 您可以将 forwarded_allow_ips 值配置为环境变量,而不必使用像 Nginx 这样的中间代理。
在我的情况下,我只是设置FORWARDED_ALLOW_IPS = *,它工作得很好。
在 ECS 中,如果您对所有 Airflow 任务(网络服务器、调度程序、工作程序等)使用一个 docker 映像,则可以在网络服务器任务配置中设置此项。
最后我自己找到了解决方案。
我在 ALB 和 Airflow Web 服务器之间引入了 nginx 反向代理:即。https 请求 ->ALB:443 ->nginx 代理:80 ->Web 服务器:8080。我通过添加 http 标头“X-Forwarded-Proto https”,让 nginx 代理告诉 Airflow Web 服务器原始请求是 https 而不是 http。
nginx 服务器与 Web 服务器位于同一位置。我将其配置设置为 /etc/nginx/sites-enabled/vhost1.conf (见下文)。此外,我删除了 /etc/nginx/sites-enabled/default 配置文件。
server {
listen 80;
server_name <domain>;
index index.html index.htm;
location / {
proxy_pass_header Authorization;
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3265 次 |
| 最近记录: |