Generic purpose http proxy for LAN access

Dear readers,
I would like to show you an example of working solution which allows to re-route requests coming to openHAB/Eclipse Smart Home into completely new locations. You might already know that openHAB has a proxy service which allows you to access LAN resources, however it requires them to be referenced from openhab sitemap.

This example is completely different as it works as kind of HTTP tunnel. Anything you specify in request gets passed to destination, without adding openhab sitemap elements. Remember - with great power there is also a great responsibility - it means that you should take care about security of deployed solution, either by securing your openhab instance or destination service.

How to do it? Simply - download connectorio-io-proxy bundle from our github: https://github.com/ConnectorIO/connectorio-io-http/releases, install as any other addon. Once you are done with that and module/bundle gets resolved you will be able to configure your own endpoints.

File: services/proxy.cfg => /etc/openhab2/services/proxy.cfg

proxy.hvac.path = /hvac
proxy.hvac.port = 80
proxy.hvac.host = 192.168.1.1
proxy.hvac.dashboard-name = HVAC

proxy.influx.path = /influx
proxy.influx.port = 8086
proxy.influx.host = 192.168.1.2
proxy.influx.dashboard-name = Influx
proxy.influx.dashboard-image = /grafana/public/app/plugins/datasource/influxdb/img/influxdb_logo.svg

proxy.grafana.path = /grafana
proxy.grafana.port = 3000
proxy.grafana.host = 192.168.1.3
proxy.grafana.dashboard-name = Grafana
proxy.grafana.dashboard-image = /grafana/public/img/grafana_icon.svg

# configuration syntax is like below
# proxy.[id].key = value

As you can see there are few standard:

  • host - where to route request
  • port - destination port (if different than 80)
  • path - from where to route

Additionally you can also register new dashboard elements which will be shown when you visit openhab homepage:

  • dashboard-name
  • dashboard-image
  • dashboard-overlay

With these - you can actually see that something works:

You do not need to specify URL - it will be taken from path option specified above. Noteworthy whole thing has chances to work also with openhab cloud - if your application or service you proxy doesn’t have any mysterious parts. Below you can find a proxied version of my HVAC panel:

(for openhab cloud - both grafana and influx did not fly nicely but I did not dig into issue)

Enjoy & have fun!

Updates
13.03.2019 - Release of 2.4.1 with small bugfixes and 2.3.0 which works with openHAB 2.3.0 (and above too btw).

4 Likes