Nginx non-root url proxy_pass not working with Luigi

164 views
Skip to first unread message

Tashrif B.

unread,
Aug 11, 2020, 4:22:16 PM8/11/20
to Luigi
Hi all,

I am trying to reverse proxy the Luigi server through Nginx. The `proxy_pass` against root URL works but not for non-root URL.

I am working on a CentOS 7 Linux machine. I launched Luigi server as luigid --address 127.0.0.1 --port 8082. I edited the default `/etc/nginx/nginx.conf` file with the following:

```
location / {
     proxy_pass http://127.0.0.1:8082;
}
```

Then curl -L http://`hostname`/ prints the `/static/visualiser/index.html` content fine and I see the following Tornado log (Luigid log):
```
2020-08-11 INFO: 302 GET / (127.0.0.1) 0.47ms
2020-08-11 INFO: 200 GET /static/visualiser/index.html (127.0.0.1) 0.77ms
```


---

However, for the **non-root** URL configuration, I run into error 404--
```
location /luigi/ {
     proxy_pass http://127.0.0.1:8082/$1;
}
```

Output of curl -L http://`hostname`/luigi/ is about error 404.

Tornado log:
```
2020-08-11 INFO: 302 GET / (127.0.0.1) 0.47ms
(2nd line is missing)
```


Because of the missing second line, it looks like either Nginx or Tornado is not able to redirect the request properly. Can anyone please help?

Best,
Tashrif

Tashrif B.

unread,
Aug 15, 2020, 2:36:34 PM8/15/20
to Luigi
I found a way that I wanted to share-- having the former configuration:

```vim

location / {
     proxy_pass http://127.0.0.1:8082;
}
```

But modifying `luigi/server.py` line 302 with `luigi/` prefix makes `curl -L http://hostname/luigi/` work:

```python
300     handlers = [
301         (r'/api/(.*)', RPCHandler, {"scheduler": scheduler}),
302         (r'/luigi/', RootPathHandler, {'scheduler': scheduler}),
303         (r'/tasklist', AllRunHandler, {'scheduler': scheduler}),
304         (r'/tasklist/(.*?)', SelectedRunHandler, {'scheduler': scheduler}),
305         (r'/history', RecentRunHandler, {'scheduler': scheduler}),
306         (r'/history/by_name/(.*?)', ByNameHandler, {'scheduler': scheduler}),
307         (r'/history/by_id/(.*?)', ByIdHandler, {'scheduler': scheduler}),
308         (r'/history/by_params/(.*?)', ByParamsHandler, {'scheduler': scheduler}),
309         (r'/metrics', MetricsHandler, {'scheduler': scheduler})
310     ]
```

I started my approach without Nginx-- I modified the `luigi/server.py` and tested just `curl -L http://127.0.0.1/luigi/` before trying the Nginx.

That being said, I am yet to find a way to solve this problem without modifying `luigi/server.py`

Thanks,
Tashrif
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages