0

I have a setup where I have multiple service running with docker compose and one Nginx (nginx:1.19-alpine), which acts as a reverse proxy for all services and serves some static files.

One service is an Influxdb container (influxdb:2.1.0-alpine) which provides a UI for webbrowsers.
I want to reverse proxy to this container, but I get problems with the static files of this container.

This would be my rule so far:

upstream database {
    server data-db:8086;
}

server {

    listen 80;

    location /influx/ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://database/;
    }
}

I get a white screen, when I browse to http://localhost:8080/influx/ (localhost:8080 is the Nginx)
The console shows me, that the static files cannot be found.

enter image description here

In the image you can see, that the browser tries to find files at / and not /influx/. That's a problem, because I have other things on /
I've seen similar questions, but can't get my setup to run properly.

JWo
  • 101
  • 1
  • There is a ton of similar questions at SF and SO (e.g. [1](https://stackoverflow.com/questions/53649885/a-little-confused-about-trailing-slash-behavior-in-nginx), [2](https://stackoverflow.com/questions/22759345/nginx-trailing-slash-in-proxy-pass-url)). Remove the trailing slash from `proxy_pass http://database/;` directive. – Ivan Shatsky Nov 15 '21 at 14:29
  • I tried that and I get the same results. – JWo Nov 15 '21 at 14:42
  • It should work. Maybe something get cached? Try from the incognito window. – Ivan Shatsky Nov 15 '21 at 14:44
  • 1
    I tried incognito window and a different browser. I thought that this should work, but somehow it doesn't. – JWo Nov 15 '21 at 15:06

1 Answers1

0

I guess there is not an real answer to this. I found this two year old Github issue: https://github.com/influxdata/influxdb/issues/15721
It is a known problem, but wasn't fixed as of now.

A workaround could be to use subdomains, so you can serve Influx on a root directory like influx.example.com/ For hosting on localhost one would have to add an entry to the hosts file and add that "domain" to the server directive of nginx.

JWo
  • 101
  • 1