Running application behind reverse proxy with subpath

Hi all,

We are running several services on a server inclunding ChirpStack.
What i’d like to do is accessing the web UI not to http://some.ip.address:8080 but thanks to a subpath like http://some.ip.address/chirpstack/ for instance.

Configuring a nginx to reverse proxy is to my knowledge not enough as we have static files.

Has anyone ever tried doing this kind of stuff please? Or maybe that’s just too complicated considering APIs interactions etc…

Thanks a lot

I don’t think this is going to work as the web-interface expects the API to be at /api/...

Okay thanks a lot Brocaar.

There’s nothing stopping you from running it on a different IP on the same server, though. There are a lot of ways to do that, the most popular/recent way is containerization, but that’s far from the only option.

I have some of this working - but not everything works as expected (live packets etc don’t display), but configuration works etc.

These are the lines I ended up adding to the Apache config:
# Chirpstack has statics and cannot be deployed in a directory - this is a terrible hack
ProxyPass /chirpstack http://localhost:8080/
ProxyPassReverse /chirpstack http://localahost:8080/
ProxyPass /chirpstack# http://localhost:8080/
ProxyPassReverse /chirpstack# http://localahost:8080/
ProxyPass /static http://localhost:8080/static
ProxyPass /api http://localhost:8080/api
ProxyPass /swagger http://localhost:8080/swagger
ProxyPass /logo http://localhost:8080/logo
ProxyPassReverse /static http://localhost:8080/static
ProxyPassReverse /swagger http://localhost:8080/swagger
ProxyPassReverse /api http://localhost:8080/api
ProxyPassReverse /logo http://localhost:8080/logo

Please let me know if you get anything else working, as I’d like to have the whole solution working if I can.

1 Like

You need a WebSocket proxy for these paths. E.g. for NGINX you would add:


        location ~ ^/api/(gateways|devices)/(\w+)/(frames|events)$ {
                proxy_pass https://127.0.0.1:8080/api/$1/$2/$3;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_read_timeout 86400s;
                proxy_send_timeout 86400s;
        }

        location / {
                proxy_pass https://127.0.0.1:8080;
        }

So I haven’t checked everything, but this works pretty well: (I have a proxy container that exposes lots of web services under 80/443)

   upstream chirpstack {
     server chirpstack_chirpstack-application-server_1:8080;
   }
   location ~ ^/chirpstack/api/(gateways|devices)/(\w+)/(frames|events)$ {
      proxy_pass http://chirpstack/api/$1/$2/$3;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_read_timeout 86400s;
      proxy_send_timeout 86400s;
    }
    location /chirpstack/ {
      sub_filter_types text/html text/css text/plain application/javascript;
      sub_filter_once off;
      sub_filter '="/static' '="/chirpstack/static';
      sub_filter '/static' '/chirpstack/static';
      sub_filter '"/swagger' '"/chirpstack/swagger';
      sub_filter '"/api' '"/chirpstack/api';
      sub_filter '"/logo/logo.png' '"/chirpstack/logo/logo.png';
      proxy_pass http://chirpstack/;
    }

This now appears to be mostly working.

1 Like

I realize this is a bit older but I have Chirpstack running. It’s on port 8080
I want to run another UI page that I need for our app; what is my best option:

  1. install apache and run on another port
    or
  2. Run it under chirpstack app server

If 1 - standard apt install ok?
if 2 - where the heck do I put the code to see it in the ui lol?

didn’t work for me, there are a lot of files that should be served…