• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Resolved "502 Bad Gateway" with nginx reverse proxy for openhab cloud

proton23

Basic Pleskian
Server operating system version
Ubuntu 20.04.6 LTS
Plesk version and microupdate number
Plesk Obsidian 18.0.52
Hi,
I'm trying to make openhab cloud (GitHub - openhab/openhab-cloud: Cloud companion for openHAB instances) work on Plesk but it seems impossible for me.
To explain briefly how it should work:
- Local openhab instance connects with UUID and secret to openhab cloud instancen. They are connected via websocket
(seems to work since local instance is shown as online)
- User calls OPENHAB.mydomain.com (where openhab cloud is running) and logs in
- Application shows a link to HOME.mydomain.com, which get proxied to the dashboard of the local instance (I my case it does not work)

This is the additional directive for openhab.mydomain.com
NGINX:
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 this the additional directive for home.mydomain.com
NGINX:
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;
}

I get "502 Bad Gateway" with this.
ChatGPT told me that I should consolidate those directives to something like this
NGINX:
server {
    listen 80;
    listen [::]:80;
    server_name myopenhab.org www.myopenhab.org home.myopenhab.org;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name myopenhab.org www.myopenhab.org home.myopenhab.org;

    charset utf-8;

    access_log /var/log/nginx/my.openhab.org-access.log;
    error_log /var/log/nginx/my.openhab.org-error.log;
    client_max_body_size 300m;

    root /var/www/html;

    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://localhost: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://localhost: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;
    }
}

How can I do something like this in Plesk?

Best regards
 
What's happening on port 3000? Is there a service installed that listens on it and responds to it?
 
Actually I'm not sure. In app.js on line 117 there is
JavaScript:
app.set('port', process.env.PORT || 3000);
and the application is running but if I run
Bash:
sudo netstat -tulpn | grep LISTEN
no service is listening on port 3000.
 
I changed
JavaScript:
app.set('port', process.env.PORT || 3000);
to
JavaScript:
app.set('port', 3000);
to make sure the app is using port 3000, but after restart there is still so service listening on port 3000.
The application is available when I access oh.mydomain. What am I missing here?
Should I open a new thread, because the topic has moved away from the title quite a bit?

Best regards
 
I was able to solve the problem.
After activating node.js I was able to access the page but there was no process listening on port 3000.
Under run nodejs commands I had to execute "run start" to make node listen on port 3000.
Now all configuration works as expected. Thanks to everyone trying to help!

Best regards
 
Back
Top