问题
I'm trying to set up Airflow behind nginx, using the instructions given here.
airflow.cfg file
base_url = https://myorg.com/airflow
web_server_port = 8081
.
.
.
enable_proxy_fix = True
nginx configuration
server {
listen 443 ssl http2 default_server;
server_name myorg.com;
.
.
.
location /airflow {
proxy_pass http://localhost:8081;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto "https";
}
}
Airflow webserver and scheduler are up and running as systemd. When I try to access https://myorg.com/airflow/, it gives Airflow 404 = lots of circles.
What could be wrong? Really appreciate your help in getting this running.
回答1:
I just had the same problem and fixed it by adding a tailing /
to the location: location /airflow/ {
instead of location /airflow {
. The tailing backslash tells nginx to remove the preceeding /airflow in uri paths to the corresponding python app.
My overall config looks as follows:
server_name my_server.my_org.net;
location /airflow/ {
proxy_pass http://localhost:9997;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
In airflow.cfg
I additionally specified:
base_url = http://my_server.my_org.net/airflow
enable_proxy_fix = False # Seems to be deprecated?
web_server_port = 9997
回答2:
I run into the same problem using https.
But using the configuration in the solution led me to another problem.
Anything other than /airflow/
location falls back to /
location.
Returning 404 errors to assets.
Using the configuration bellow solved the issue:
location ^~ /airflow/ {
proxy_pass_header Authorization;
proxy_pass http://localhost:8080/airflow/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
}
来源:https://stackoverflow.com/questions/56105608/airflow-nginx-set-up-gives-airflow-404-lots-of-circles