Cannot access airflow web server via AWS load balancer HTTPS because airflow redirects me to HTTP

后端 未结 4 772
夕颜
夕颜 2021-01-05 08:32

I have an airflow web server configured at EC2, it listens at port 8080.

I have an AWS ALB(application load balancer) in front of the EC2, listen at https 80 (facing

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-05 09:12

    Finally I found a solution myself.

    I introduced a nginx reverse proxy between ALB and airflow web server: ie. https request ->ALB:443 ->nginx proxy: 80 ->web server:8080. I make the nginx proxy tell the airflow web server that the original request is https not http by adding a http header "X-Forwarded-Proto https".

    The nginx server is co-located with the web server. and I set the config of it as /etc/nginx/sites-enabled/vhost1.conf (see below). Besides, I deletes the /etc/nginx/sites-enabled/default config file.

    server {
        listen 80;
        server_name ;
        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;
        }
    }
    

提交回复
热议问题