I have a OH4 instance running on a Raspberry Pi (http://192.168.1.151:8080/) behind a wifi router. I can’t access it directly from outside. On the same network I have an old laptop (Dell Latitude 2100) running nginx I want to configure as reverse proxy. Nginx is listening on port 4040 and I want to access my OH instance with URL http://dell_latitude_2100:4040/raspi3-01/openhab/
Here is my actual nginx config on the laptop; I found some tips on forums… and I did my best…
I didn’t look at myopenhab yet. But I’m trying to stay as independent as possible from external services
And here are some more details: For my research activities (on data governance) I’m using several IoT platforms. I’m currently using two OH4 instances (1 Raspberry Pi 3 B+, 1 Raspberry Pi 4), one HomeAssistant instance (another Raspberry Pi 3 B+), one (old) laptop to fetch open data and send it via MQTT, a standalone weather station, etc. So I put all those devices on a private network behind my router, which is itself behind the university NAT. No access from outside for now, even from the university network (I don’t want students to “enter” my testbed). But they can publish data to outside that I get on my working laptop (running another OH4 instance and another HA instance and some other programs…).
When I’m near my wifi router, I can connect to it and, being inside my private network, I can access GUI for OH or HA. But when I’m “anywhere else” on the university network, I want to be able to access those GUIs through a nginx proxy for instance (cf. various “location” entries). Doing so, I’ll need to open only one port on my router (ex: 4040).
Hope I succeeded to explain my needs
But if myopenhab can go through 2 routers, doesn’t need to open too many ports and can manage several OH instances (or do I need several accounts ?), it could be a interesting solution.
I suggest not spending time on reinventing the wheel on basic stuff to figure out all the details. That’s a totally unnecessary, time and nerves consuming task.
Put your time and energy into better home automation instead.
So my prime suggestion would be to check out myopenhab.org, too.
It’s professionally managed, reliable, someone operates it for you 24/7, and it’s free (unlike is with Home Assistant …) so why not use it ?
If by all means you want to do it on your own, use openHABian. It has a ready-to-use nginx option.
myopenhba.org can work with any OH instance that can reach out to the Internet and requires 0 open ports. The OH initiates the connection t0o myopenhab.org so there’s no need for anything from the Internet to initiate a connection through your firewall (i.e. no open ports).
However, you will need a separate account for each OH instance.
You can run your own instance of myopenhab.org (i.e. the openHAB Cloud Server) but that needs to be accessible from the Internet. All you’ve really done is move the original problem, not solved it.
If that doesn’t work for you or you need a more universal solution to access other services than OH, a VPN of some sort might be a better solution. It’s easier to secure and monitor a VPN than it is a reverse proxy. Some like Tailscale do not even require opening ports.