Accessing openHAB’s dashboard redirects to same url

I tried to get my own openhab cloud instance running on my Plesk administered server a few months ago, but failed miserably. After creating a thread today because of an error message, I started all over again and am now back to the way it was before the error message

Exactly as described in this link Access dashboard from private openhab cloud - #3 by tiller

the message “Your openHAB is online. Click here to access your openHAB’s dashboard” appears, giving a link to the exact same url of my instance (https://oh.[MYDOMAIN])

I found this threads

but since I’m using Plesk I could not adapt. I tried to get another instance running on the subdomain https://home.[MYDOMAIN] because I have read this several times, but the configuration seems to be incorrect and the files from Wolfgang I can not adapt because the instances are started from Plesk and not from systemd.

It is not clear to me what is meant by “proxy”. A simple forwarding will probably not be enough. In addition, the question arises: Does it have to be proxied from subdomain oh to home or vice versa?
And what should be done if proxiing works?

I would really appreciate it if someone could shed some light on my darkness.

Thanks in advance and best regards

how are additional services installed under Plesk ?
Disclaimer: I have no experience with Plesk so the following assumption might not be correct.

This is a very old ( 4 years ago ) one so most probably not applicable any longer.
But never the less if it works that way it also should work the systemd way assume you have shell ?

subdomoain home is fixed in the code.

Proxy is used for two purposes:

  1. nginx logic takes care to redirect the traffic related to socketapp, proxyapp, webapp
  2. you need proxy ( nginx ) setup in case you need to redirect a clck on home.[MYDOMAIN] to oh.[MYDOMAIN}

Yes, I have root access.

I know, this was also mentioned here.

Where should this traffic be redirected to?

I assume that the lack of understanding of how it works is my main problem.
For openhab I have created the subdomain oh.mydomain.de. With the openhab connector I point to this URL and through the UUID and secret this can log my openhab from home to the openhab cloud instance and is shown as online.
Now for the point I don’t understand: what happens when you want to view the dashboard? Why is it redirecting to the same URL?
If I have a second instance running at home.mydomain.de, is my openhab registered there as well? And what does this instance do then? What option has to be set so the link on home-page refers to another link?

Best regards

Have a look to the nginx config files that I uploaded in 2 or 3 other threads.
I remember that at least one person gave a positive comment and also an addition or correction.
Take that one and search for IP addresses in the range of 192.168 ( if I didn’t replace them ).
This should be next to where upstream for socketapp, webapp and proxyapp are defined.
There are also two files that that the nodejs. One with port 3000 and one with port 3001. These are the services nginx will redirect to.The IP addresses need to be replaced with yours.

It also took me a bit to get it running.

I think that should be ok.

in the file file config.json there is an entry called proxyHost that need to point to your home.mydomain.de instance ( meaning that name needs to be put there ).
Once that is done and two instances of the nodejs app are started ( one for port 3000 and one for 3001 ) then when you connect to your instance the link you need to click on should point to home.mydomain.de.

We have a long weekend and I’m away, so it will take a few days until I can give further information.

1 Like

I tried to setup a second domain with the git repo of openhab cloud but it seems like Plesk has a problem with that.


(under the marker is my main domain)
Therefore I don’t know if it’s worth the effort to get a second instance running or if I should try to get it running with one instance right away. :confused:
@Wolfgang_S You mentioned in some thread that somebody made it work, right?

Yes, see the thread you already linked to ( Not able to access openHAB home dashboard on custom openHAB cloud instance ). Further down in the thread you can find a comment that other user(s) used that configuration as well.
I must admit that this is most probably not tested in a plesk environment.

The openhab-cloud instance is installed one time. There are two systemd started nodejs processes running.

I’ve been trying to get more into how openhab cloud works, but somehow I’m not getting anywhere. Using the configuration property proxyHost, I can specify the URL that the link in the overview should point to. This URL must then be forwarded via the reverse proxy, but I just do not know where to. You use in your configuration localehost:3000 and localehost:3001, is there a specific reason for this? On my server the Dr.Web application is running on port 3000, which seems to be always the case with Plesk.

The node app of openhab-cloud uses the ports 3000 and 3001.
As the node app and nginx is running on the same host localhost can be used.
I just had a look into my configuration file and I see that I am using the IP address of this host at the moment.

netstat -tulpn | grep node
tcp6       0      0 :::3001                 :::*                    LISTEN      862/node            
tcp6       0      0 :::3000                 :::*                    LISTEN      858/node

The service file that is used to start the node app ( app.js ) uses variables that define the port to be used during runtime. So in case your port 3000 is already in use by an other service this would be the place to setup which port to use.

So, I stopped the Dr.Web service (which means port 3000 is available) and as additional directive (they get inclueded with include "/var/www/vhosts/system/oh.mydomain.com/conf/vhost_nginx.conf";) for mydomain.com I tried this

location /css {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/css;
}
location /js {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/js;
}
location /img {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/img;
}
location /bootstrap {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/bootstrap;
}
location /font-icons {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/font-icons;
}
location /fonts {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/fonts;
}
location /js-plugin {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/js-plugin;
}
location /staff/js-plugin {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/js-plugin;
}
location /downloads {
	alias /var/www/vhosts/mydomain.com/oh.mydomain.com/public/downloads;
}

location ~ /.well-known {
	allow all;
}

location ~ ^/(socket.io|rest|images|static|rrdchart.png|chart|openhab.app|WebApp|CMD|cometVisu|proxy|greent|jquery|classicui|ui|basicui|doc|start|icon|habmin|remote|habpanel|ifttt/v1/actions/command) {
	proxy_pass http://SERVER-IP:3000;
	proxy_redirect off;
	proxy_http_version 1.1;
	proxy_set_header Host $host;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto https;
}

location / {
    proxy_pass http://SERVER-IP:3000;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
}

And the additional directives for home.mydomain.com looks like this

location ~ /.well-known {
	allow all;
}

location / {
	proxy_pass http://<SERVER-IP>:3000;
	proxy_redirect off;
	proxy_http_version 1.1;
	proxy_set_header Host $host;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto https;
}

With this I get an “Bad Gateway 502” and proxy_access_ssl_log file shows this "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 502 1005 "-" "okhttp/3.8.1"

If I remove this part from the mydomain.com config

location / {
    proxy_pass http://<SERVER-IP>:3000;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
}

the openhab cloud service page is shown but the locale instance will not be recognized as online.
proxy_access_ssl_log file still shows "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 502 1005 "-" "okhttp/3.8.1"
proxy_error_log shows 2023/06/15 22:55:00 [error] 834848#0: *585874 connect() failed (111: Connection refused) while connecting to upstream, client: <HOME-IP>, server: oh.mydomain.com, request: "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1", upstream: "http://<SERVER-IP>:3000/socket.io/?EIO=3&transport=websocket", host: "oh.mydomain.com"

openhab log of the local instance shows this [WARN ] [okhttp3.OkHttpClient ] - A connection to https://oh.mydomain.com/ was leaked. Did you forget to close a response body?

If I remove everything, in proxy_access_ssl_log file I get this

[15/Jun/2023:23:06:03 +0200] "GET / HTTP/1.1" 304 0 "https://oh.mydomain.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
[15/Jun/2023:23:06:04 +0200] "GET /js-plugin/jquery-cookie/jquery.cookie.js?_=1686863164177 HTTP/1.1" 200 768 "https://oh.mydomain.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"
[15/Jun/2023:23:06:04 +0200] "GET /apple-icon.png HTTP/1.1" 499 0 "https://oh.mydomain.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"

When the local instance gets recognized I get this in the openhab.log
2023-06-15 23:05:01.619 [INFO ] [io.openhabcloud.internal.CloudClient] - Connected to the openHAB Cloud service (UUID = 2c...5a, base URL = http://localhost:8080)

But when clicking on the link to the dashboard I get “Bad Gateway 502”
and proxy_access_ssl_log file of home.mydomain.com shows
[15/Jun/2023:23:32:27 +0200] "GET / HTTP/1.1" 502 1005 "https://oh.mydomain.com/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0"

proxy_error_log of home.mydomain.com shows
2023/06/15 23:22:34 [error] 837299#0: *587035 connect() failed (111: Connection refused) while connecting to upstream, client: <HOME-IP>, server: home.mydomain.com, request: "GET / HTTP/1.1", upstream: "http://<SERVER-IP>:3000/", host: "home.mydomain.com", referrer: "https://oh.mydomain.com/"

Any ideas?

Best regards

Connection refused normally means that there is either a blocking firewall or there is no service running/listening on the specified port.
You started two instance of node app.js ?

No, the result of my last attempt was my post above.
Starting a job with a script like in the thread you posted is not an option for me, because I already tried to install something bypassing Plesk once, screwed up the system and ended up having to reinstall the whole server from scratch. Nothing I wanna do again.
That’s why I’m trying to make it work with one instance but I will ask in Plesk forum if there is a way to start two instances within Plesk.
The message you pointed out also states "upstream: "http://<SERVER-IP>:3000/socket.io"
Should the directive proxy to address http://localhost:3000/socket.io?

Best regards

@Wolfgang_S You told me you use port 3000 because openhab cloud is using it.
Just to make sure I edited app.js app.set('port', 3000);
I also tried port 4000 but when I run sudo netstat -tulpn | grep LISTEN
neither port 3000 nor 4000 are ever used, so I guess this could be the root cause why it’s not working.

it is the default port that is being used by the nodejs app ( app.js ).
In code of app.js it is written ( in code) that it checks for the value of the environment variable PORT.
If PORT is not set then it falls back to 3000 as default value.

Do you start node to run apps.js ?
I would assume you either don’t run it or it fails or a different PORT value is set as environment variable.
The netstat you used should show all the binaries that are attached to a listening port.
Check for binary which is called node.

Nginx reverse proxies the request from the internet to the listending port 3000 / node apps.js.
apps.js communicates with your openhab instance.

1 Like

@Wolfgang_S you are my personal hero!
You never gave up on me! :hugs:

I will explain my mistake:
After pulling the git repo you will find the node dashboard with the option to “activate node.js”
nodejs_dashboard_activate

After clicking that button the website was available and I had the option to restart the app.

But after your comment

I started to look further and there is a tab to run Node.js commands
nodejs_run_commands

and there was the possibility to start node

Now a node instance is listening on port 3000

and the configuration provided above works like it is.

I have not been able to change the port the app is listening on yet but I thinks that’s something for the Plesk forum.

Thank you SOOO MUCH!

Best regards

1 Like