Serving from subpath/domain issue when accessing locally

Hello,
I’m serving via nginx on a single machine two instances of grafana one under /path1 and the other one on /path2. The two instances of grafana are hosted on two different LANs which are accessible locally one another via a VPN (router based).

192.168.188.x → LAN1 of path1
192.168.1.x → LAN2 of path2

In each docker compose files i’m adding the following (the example is just for path1 but an identical with path2 is used).

- GF_SERVER_DOMAIN=domain.com
- GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s:%(http_port)s/path1/
- GF_SERVER_SERVE_FROM_SUB_PATH=true

I’ve added those commands because i’m exposing them over the internet via those two subpath.
The issue for me is that:

  1. when i access locally from the same network i can access via the local ip
  2. when i access locally from the other network the grafana answers with a 301 moved permanently forcing the connection to access from the domain.com path.
  3. when i access externally nginx handles the proper domain (the grafana env variable doesn’t play any role).

Any idea why point 2 is as such?
Do i need to use those env variables?