Nginx reverse proxy: /login not honouring baseurl

As I attempt to browse to www.domain.com/nms the url changes to www.domain.com/login when it should be www.domain.com/nms/login. Browsing by IP works as in I can login OK, but some images are broken and going to Settings then attempts the domain.com URL, and as I do not have a cookie for that, goes straight to domain.com/login and can’t progress.

librenms@host:~$ ./validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.44-24-g2e34c73
DB Schema | 269
PHP       | 7.0.32-0ubuntu0.16.04.1
MySQL     | 10.0.36-MariaDB-0ubuntu0.16.04.1
RRDTool   | 1.5.5
SNMP      | NET-SNMP 5.7.3
====================================

[OK]    Composer Version: 1.7.2
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database schema correct

I have baseurl set in config.php as “/nms/”, the problem also persists if baseurl is not set and set to “https://www.domain.com/nms/”, and here is my nginx reverse proxy config:

location /nms/ {
        proxy_pass http://192.168.0.104/;
        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 $scheme;
        include conf.d/basicauth.conf;

I have run ./daily.php and ./validate.php, no issues. LibreNMS is running on nginx too. This issue has been going on for some months so sadly I can’t tell you when I first noticed it or which version.

Have you tried https://docs.librenms.org/#Support/FAQ/#my-reverse-proxy-is-not-working

I didn’t, sorry. Having looked at that and added trusted reversy proxy variable in .env, no improvement. As it stands I have APP_URL (.env) and base_url (config.php) both set as https://www.domain.com/nms/.

Here’s a very similar and recent issue: [BUG] LibreNMS Web UI: base_url not taken into account

Reverse proxy with a sub directory and LibreNMS without one is not really working. I haven’t figure how to fix this in a way that doesn’t break other configurations.

To be fair, I wouldn’t be offended by the idea on moving everything to sub domains as I think letsencrypt now supports wildcard.

However if you’re keen to fix I’m happy to offer SSH access to my LibreNMS host for you.

Like I said the problem isn’t making that config work, it is doing it without breaking others.

Thanks for the offer.

No sweat, well I’m rocking on a sub domain for now and I’m happy to stay on this for the foreseeable. Wildcard certificates from letsencrypt was the only reason why I chose directories instead of sub domains in the first place.