Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST reporting incorrect links? #161

Open
photon-schiesser opened this issue Feb 6, 2018 · 2 comments
Open

REST reporting incorrect links? #161

photon-schiesser opened this issue Feb 6, 2018 · 2 comments

Comments

@photon-schiesser
Copy link

Hi there,

I am running openhab-cloud via docker on an Ubuntu system. The docker image maps port 80 inside the nginx docker image to port 8080 on the Ubuntu system. The Ubuntu system is behind a router/firewall on my home network. The router forwards the internet-facing port 8000 to port 8080 of the Ubuntu system.

I have a DDNS service, hostname ScheissSchiesser.com (not really). Here are my configs:

config.json:

{
    "system": {
      "host": "ScheissSchiesser.com",
      "port": "8000",
      "protocol": "http",
      "logging": "info",
      "subDomainCookies": false,
      "muteNotifications": false
...

If I visit http://ScheissSchiesser.com:8000/rest/sitemaps, I get the following response:

[{"name":"default","label":"Schiesser Home","link":"http://ScheissSchiesser.com/rest/sitemaps/default","homepage":{"link":"http://ScheissSchiesser.com/rest/sitemaps/default/default","leaf":false,"widgets":[]}},{"name":"presence","label":"Presence Sensors","link":"http://ScheissSchiesser.com/rest/sitemaps/presence","homepage":{"link":"http://ScheissSchiesser.com/rest/sitemaps/presence/presence","leaf":false,"widgets":[]}},{"name":"_default","label":"Home","link":"http://ScheissSchiesser.com/rest/sitemaps/_default","homepage":{"link":"http://ScheissSchiesser.com/rest/sitemaps/_default/_default","leaf":false,"widgets":[]}}]

Note that the links in the response of the REST API do not contain the correct port number.

Using a browser to view my sitemaps through the link on the openhab-cloud homepage (where it says "You are using openHAB 2.x. Click here to access your openHAB's dashboard") works perfectly (it provides the correct link with port 8000).

However, presumably because of the above incorrect REST response, using the OpenHAB Android app with openhab-cloud on port 8000 does not work (see openhab-android issue 674).

Is that REST response correct? Do I need to configure another setting in my openhab-cloud instance? Or is this indeed a bug?

@MasterGollom
Copy link

MasterGollom commented Feb 10, 2018

Hi there,
I'm experiencing the exact same problem, that I cannot connect to my openhab via the cloud on my android device. I'm running a openhab2 instance on one server and a openhab-cloud instance on another server. Openhab runs on 8080 and the openhab-cloud runs on ssl 443 (https).

Visiting https://railsvr.modelleisenbunn.eu/rest/sitemaps my response is quite the same as ScheissSchiesser's.

[{"name":"home","label":"House","link":"http://railsvr.modelleisenbunn.eu/rest/sitemaps/home","homepage":{"link":"http://railsvr.modelleisenbunn.eu/rest/sitemaps/home/home","leaf":false,"timeout":false,"widgets":[]}},{"name":"_default","label":"Home","link":"http://railsvr.modelleisenbunn.eu/rest/sitemaps/_default","homepage":{"link":"http://railsvr.modelleisenbunn.eu/rest/sitemaps/_default/_default","leaf":false,"timeout":false,"widgets":[]}}]

Note that I'm visiting a https url and REST Api responds with a http url. Anyone can help us here please?

@richterger
Copy link

richterger commented Nov 16, 2019

I have the same issue, the following patch solves the problem for me:

--- routes/index.js.old	2019-11-16 15:16:27.410314578 +0100
+++ routes/index.js	2019-11-16 15:14:31.760354843 +0100
@@ -367,7 +367,8 @@
     delete requestHeaders['x-forwarded-for'];
     delete requestHeaders['x-forwarded-proto'];
     delete requestHeaders['connection'];
-    requestHeaders['host'] = req.headers.host || system.getHost() + ':' + system.getPort();
+//    requestHeaders['host'] = req.headers.host || system.getHost() + ':' + system.getPort();
+    requestHeaders['host'] =  system.getHost() + ':' + system.getPort();
     requestHeaders['user-agent'] = 'openhab-cloud/0.0.1';
     // Strip off path prefix for remote vhosts hack
     var requestPath = req.path;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants