Owntracks with private Openhab-cloud

Have anyone configured Owntracks through a private openhab-cloud? Wondering what it takes to point owntracks to a private openhab-cloud instead of openhab at home/office behind a firewall.

Yes I did, but it has nothing to do with the Obenhab-cloud itself

I have a private root server with the obenhab-cloud and a “secure” mqtt server installed on.
My smartphone has the Owntracks app with the secure mqtt server configured.
At home i have a raspberry Pi with openhab. (there I have another internal mqtt server running)
openhab knows both of the mqtt servers and my owntrack items use the secure mqtt server.

Thanks for the reply and time taken to nicely illustrate it @Felix_Raetz

My implementation is through http, not through mqtt. So I may have to do something more at the private openhab-cloud side than that is mu guess.

I have exactly the same. Did you came any further on this @anjana55?

My OwnTrack version 2.1.3 on Android reports in the status menu (Endpoint state message):

Java.net.SocketTimeoutException:timeout

It seems like Owntrack tries to send something to my OpenhabCloud,but gets no response. My OwnTrack setup works fine with myopenhab.org

This puzzels me:
The URL that you need to configure in OwnTrack is :
https://home.myopenhab.org/gpstracker/owntracks
Note home as start of the URL!

That is a different URL than configured into the OpenHab App:
https://myopenhab.org

Anyone has a clue? Is this a nginx trick that is bound to the home.openhab.org subdomain, or a node.js trick?
Should I also configure an extra subdomain?

Any help is appreciated!

Found the solution! :grinning:
See issue #231 on GitHub.

There are basically two solutions.

  1. Either create another subdomain and process those URL request different (like http://home.myopenhab.org instead of https://myopenhab.org)

  2. Add two small correcties to the javascript files.

I tried the 2nd solution and it works!

The GitHub link shows the changes a bit difficult to read. Here is what to do:

On your private MyOpenhab server, go to the directory (changes mydomain.com to the domain you actually using):

/var/www/mydomain.com/openhab-cloud

In app.js, change the line:

if (!req.path.match('/rest*') && !req.path.match('/oauth2/token') && !req.path.match('/ifttt/*') && !req.path.match('/remote/*'))

into (add the gpstracker exception):

if (!req.path.match('/rest*') && !req.path.match('/oauth2/token') && !req.path.match('/ifttt/*') && !req.path.match('/remote/*') && !req.path.match('/gpstracker/*'))

In addition, in the file routes/index.js, after the line:

app.all('/habpanel/*', this.ensureRestAuthenticated, this.preassembleBody, this.setOpenhab, this.ensureServer, this.proxyRouteOpenhab.bind(this));

add the following line:

app.all('/gpstracker/*', this.ensureRestAuthenticated, this.preassembleBody, this.setOpenhab, this.ensureServer, this.proxyRouteOpenhab.bind(this));

Then restart your node.js in the way you usually do.

I need some more timing to examine this patch and its consequences, but wouldn’t wait telling the community. Many thanks to @DerOetzi :pray:

For the OpenHab 3 sources, this patch above still applies. However, there is an more elegant way to do this, according to the GITHUB discussion.
If your domain name is starting with “home”, then this patch is not necessary anymore. Like for instance:
https://home.mydomain.com

Do I understand this correctly @digitaldan ?

This may be to any help to some of you if you get an error message in OwnTracks, or a curl test statement which simultates OwnTracks, like this:

ForbiddenError: invalid csrf token
at csrf (/opt/openhabcloud/node_modules/csurf/index.js:112:19)
at /opt/openhabcloud/app.js:253:9
at Layer.handle [as handle_request] (/opt/openhabcloud/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/opt/openhabcloud/node_modules/express/lib/router/index.js:317:13)
at /opt/openhabcloud/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/opt/openhabcloud/node_modules/express/lib/router/index.js:335:12)
at next (/opt/openhabcloud/node_modules/express/lib/router/index.js:275:10)
at /opt/openhabcloud/app.js:247:5
at Layer.handle [as handle_request] (/opt/openhabcloud/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/opt/openhabcloud/node_modules/express/lib/router/index.js:317:13)
at /opt/openhabcloud/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/opt/openhabcloud/node_modules/express/lib/router/index.js:335:12)
at next (/opt/openhabcloud/node_modules/express/lib/router/index.js:275:10)
at SessionStrategy.strategy.pass (/opt/openhabcloud/node_modules/passport/lib/middleware/authenticate.js:346:9)
at SessionStrategy.authenticate (/opt/openhabcloud/node_modules/passport/lib/strategies/session.js:75:10)
at attempt (/opt/openhabcloud/node_modules/passport/lib/middleware/authenticate.js:369:16)
at authenticate (/opt/openhabcloud/node_modules/passport/lib/middleware/authenticate.js:370:7)
at Layer.handle [as handle_request] (/opt/openhabcloud/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/opt/openhabcloud/node_modules/express/lib/router/index.js:317:13)
at /opt/openhabcloud/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/opt/openhabcloud/node_modules/express/lib/router/index.js:335:12)
at next (/opt/openhabcloud/node_modules/express/lib/router/index.js:275:10)