I am building a temperature monitoring probe with RPI 3+ B. I have an a container running Grafna and another running wifi-connect. Both these need to use port 80 ( I can’t get it working another way.) If allocate port 80 to wifi-connect in dockercompse then grafna stops being available and if I allocate port 80 to both of them . When I connect to capacitive portal to connect wifi grafna charts shows up. I have tried changing ports that doesn’t help. Sorry if this is a really stupid question
Port 80 inside the containers or outside them (on the Pi)? Having two listeners on the same host port will of course conflict, and wifi-connect will wantnetwork_mode: "host", which limits your port options in docker-compose (and there is no need to allocate port 80 to wifi-connect when it has host network access). However, wifi-connect does have an internal port setting that might let you free up port 80 on that end.
Alternatively, if grafana can run without host mode, then you could map a different external port to port 80 inside the container:
ports:
# outside:inside
- "3000:80"
The dashboard would then be available at [local address]:3000.
To add to what @mber said above, I would suggest mapping the internal ports 80 to whatever external ports you would like. Is there an issue running the following configuration?
Unfortunately the public URL can only point to port 80 or 443 at this point, so with the wifi-connect block you won’t be able to use the Public URL for a Grafana service on port 80.
We are aware this is a friction point so we have been actively redesigning our Public URL backend for some time now in order to expose more than one service. There will likely be an announcement when we have updates.
You might be able to setup a reverse proxy with nginx or similar to help with this (see for example here).
You could then have the URL <host>/grafana map to <grafana container>:80 and <host>/ to <wifi-connect container>:80
That way, by default you would land on your wifi-connect interface, but still have the option to go to Grafana.
@Ausyp can you share your whole setup?
That will make it easier to see where things could go wrong (and optionally test things out locally).
At the very least we would need to see your Docker/Balena and Grafana configuration
Note that if your nginx runs in Docker/Balena and on the same network as Grafana, you could simply use the container name as host and port 80 and won’t need to use the exposed port 3000.
This (probably) isn’t your problem, but might be nice to keep in mind.
Edit: actually, the location / pointing to 127.0.0.1:80 could cause a routing loop that your server won’t like.
Hey @ausyp, as mentioned above you probably don’t want to point to 127.0.0.1 inside the nginx container, and should instead point to each service name :port. Something like this:
Note though that since wifi-connect has to run in host networking mode, your nginx service probably can’t listen on port 80. However port 443 should be fine.