Search code examples
nginxreverse-proxyairflow

Airflow + Nginx set up gives Airflow 404 = lots of circles


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.


Solution

  • 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