How to access influx through apache reverse proxy

Hi
I have an influx instance that listens on port 8086.
I can access the UI on http://ip.ip.ip.ip:8086 and it works fine.
Now I would like to connect to influx through an apache proxy using a specific url.

I added this piece of code in /etc/apache/site-enabled/000-default.conf

        <Location "/influx">
                ProxyPass http://localhost:8086
                ProxyPassReverse http://localhost:8086
                ProxyPreserveHost on
        </Location>

It works fine when I perform query using influxdb_client but the UI gives a blank page.

If I use firefox network monitor, I can see that the page tries to download fa4773d142.js but it should download influx/fa4773d142.js

Is there a way to configure apache or influx so that it takes into account the “influx” that should be added?

Bests

Hello @Cedric_Boudinet,
I’m really not sure.

Perhaps:
https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html

<VirtualHost *:80>
    ...
    
    <Location "/influx">
        ProxyPass http://localhost:8086
        ProxyPassReverse http://localhost:8086
        ProxyHTMLURLMap http://localhost:8086 /influx
        SetOutputFilter proxy-html
        RequestHeader unset Accept-Encoding
        ProxyPreserveHost on
    </Location>

    ...
</VirtualHost>

What are your logs?

sudo tail -f /var/log/apache2/error.log

Hello @Anaisdg
No it doesn’t work. The problem is still the same. I have nothing in the error log.
Just this in access.log:
192.168.56.1 - - [26/Sep/2023:09:20:29 +0200] “GET /influx/ HTTP/1.1” 200 922 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0”
192.168.56.1 - - [26/Sep/2023:09:20:29 +0200] “GET /fa4773d142.js HTTP/1.1” 404 492 “http://192.168.56.115/influx/” “Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0”

GET /influx gives 200 which is fine
GET /fa4773d142.js gives 404 because it should be /influx/fa4773d142.js

Hi again @Anaisdg
I managed to get one step further. With this configuration:

         <Location "/influx">
                 ProxyPass http://localhost:8086
                 ProxyPassReverse http://localhost:8086
                 ProxyHTMLURLMap / /influx/
                 SetOutputFilter proxy-html
                 RequestHeader unset Accept-Encoding
                ProxyPreserveHost on
         </Location>

/fa4773d142.js is modified to /influx/fa4773d142.js in the html code.

But then the js code sends GET requests for /21dc121c3b.js /78604747f7.js … etc … instead of /influx/21dc121c3b.js
Do you know if this possible to remap urls in js code as well? Or to configure the js framework with a base url?
Bests
Cedric