Score:0

Nginx: reverse proxy Influxdb can't find static files

cn flag
JWo

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.

Ivan Shatsky avatar
gr flag
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.
JWo avatar
cn flag
JWo
I tried that and I get the same results.
Ivan Shatsky avatar
gr flag
It should work. Maybe something get cached? Try from the incognito window.
JWo avatar
cn flag
JWo
I tried incognito window and a different browser. I thought that this should work, but somehow it doesn't.
Score:0
cn flag
JWo

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.