[SOLVED] Local myopenhab not working with gpstracker

I’ve been running a local myopenhab instance for a while using these instructions successfully and I’ve noticed that after upgrading to 2.4 I saw the GPSTracker binding and thought i’d give it a go but it doesn’t seem to work and gives me a 403 error in the owntracks app and when going to https://myopenhab.mydomain.com/gpstracker/owntracks, it just gives me “Cannot GET /gpstracker/owntracks”. I tried to upgrade by deleting my /var/www/myopenhab.mydomain.com/openhab-cloud folder and pulling the latest copy from https://github.com/openhab/openhab-cloud but that seems to have the same issue. I did get it to give me a 405 “HTTP method GET is not supported by this URL” error in my browser but still a 403 in owntracks my adding this to /routes/index.js between lines 238 and 239 but I’m not sure if I’m going down the right path or if so, what needs to change:

Routes.prototype.setupProxyRoutes = function (app) {
...
app.all('/gpstracker/*', this.ensureRestAuthenticated, this.preassembleBody, this.setOpenhab, this.ensureServer, this.proxyRouteOpenhab.bind(this));
}

To test, I switched my openhab instance to myopenhab.org and it seems to work fine so I don’t think it’s an issue on my openhab server but somewhere in the myopenhab side. Any ideas?

Looking at the app.js output and it seems that every time owntracks tries to post an update, this gets output in the log/console of my myopenhab server. I’ve double checked the credentials and they are good as I can log into openhab.mydomain.com with them and open paper ui, habmin, etc.

ForbiddenError: invalid csrf token
    at csrf (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/csurf/index.js:112:19)
    at /var/www/openhab.mydomain.com/openhab-cloud/app.js:281:9
    at Layer.handle [as handle_request] (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:317:13)
    at /var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:335:12)
    at next (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:275:10)
    at /var/www/openhab.mydomain.com/openhab-cloud/app.js:275:5
    at Layer.handle [as handle_request] (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:317:13)
    at /var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:335:12)
    at Context.next (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:275:10)
    at Context.actions.pass (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/passport/lib/passport/context/http/actions.js:77:8)
    at SessionStrategy.authenticate (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/passport/lib/passport/strategies/session.js:67:10)
    at attempt (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/passport/lib/passport/middleware/authenticate.js:243:16)
    at Passport.authenticate (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/passport/lib/passport/middleware/authenticate.js:244:7)
    at Layer.handle [as handle_request] (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:317:13)
    at /var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:335:12)
    at next (/var/www/openhab.mydomain.com/openhab-cloud/node_modules/express/lib/router/index.js:275:10)

It turns out I was on the wrong track after seeing issue #177 in github where it was mentioned that the host name has to be “home” for basic authentication. I rolled back the change I mentioned earlier and set up a cname on my DNS for home.openhab.mydomain.com, pointing to openhab.mydomain.com and got another cert for the new home.openhab virtual host. I then copied the original nginx config file and just changed the server name and cert name entries to point to home.openhab and now everything is working. OwnTracks posts successfully to https://home.openhab.mydomain.com and my existing alexa skill still works communicating to https://openhab.mydomain.com. Just gotta figure out how to get the “Click here to access your dashboard” link to point to home.openhab like myopenhab does and I’ll be all set

1 Like

Hi @zolakk, thanks for sharing that problem.

I am in the same situation right now. I want to switch to GPSTracker, but with the basic Openhab Cloud installation I am not able to use it. I receive the “Cannot GET /gpstracker/owntracks” message.
You say I have to enable a home.MYOpenHABCloudSever.de subdomain to access it?
Can you help me to do that?
Do I have to change the /etc/nginx/sites-enabled/MYOpenHABCloudSever.de file?

Thanks for your help

You need to go to whoever is handling the DNS for “MYOpenHABCloudServer.de” (typically whoever you registered that domain name with but not always) and add a home.myopenhabcloudserver.de entry in their DNS that points to the same IP. How that is done depends on the DNS provider so you’ll have to check with them on how to do that. You’ll also need to make a copy of your /etc/nginx/sites-enabled/MYOpenHABCloudSever.de file and change all the references of MYOpenHABCloudSever.de to home.MYOpenHABCloudSever.de so your server responds to both MYOpenHABCloudSever.de and home.MYOpenHABCloudSever.de. You’ll also need a new certificate for home.MYOpenHABCloudSever.de unless you have a wildcard cert for MYOpenHABCloudSever.de.

2 Likes