Hello everybody,

I am wondering whether Airflow uses absolute links to get its static content? I am trying to put Airflow behind a nginx proxy into a subdirectory. I get the following situations:

## Case 1: forward root directory

### nginx.conf

```
location / {
    proxy_pass http://localhost:17000/;
}
```

### Result

* this works, but does not use the desired subdirectory...


## Case 2: forward airflow directory - simple

### nginx.conf

```
location /airflow/ {
    proxy_pass http://localhost:17000/;
}
```

### Result

* the html/main page gets fetched ok
* the browser console shows that it tries to fetch static content from
  ``server_url/static`` instead of ``server_url/airflow/static``
* a ``curl server_url/airflow/static/main.css`` works


## Case 3: forward airflow directory - advanced

### nginx.conf

```
location /airflow/ {
    proxy_pass http://localhost:17000/;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}
```

### Result

* url in browser changes to ``server_url/admin`` instead of ``server_url/airflow/admin``
* nginx returns a ``404 Not found``


## Workaround

rewrite "static" urls, together with the configuration from Case 2:
```
rewrite ^/(static|admin|api)/(.*) /airflow/$1/$2;
```

This fixes the above issues, but is "hacky". Is there a better solution? Is this a bug? Am I missing something? Thanks in advance!



--
Andreas Koeltringer
Mail:   [email protected]

Reply via email to