• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.
  • 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.

Issue 502 error Node and Angular SSR

igorosabel

New Pleskian
Server operating system version
Debian 11.11
Plesk version and microupdate number
18.0.69 #3
Hi!
I am setting up an Angular app that uses SSR on a Linux Debian 11.11 server with Plesk Obsidian 18.0.69. I have installed NodeJS Toolkit and I have enabled Node on a subdomain where the app will go.

The Angular app is using Angular 19.2.10, and the Node configuration is this:

Code:
Node.js version: 22.15.0
Package administrator: npm   
Document root: /dev.domain.com/public/dist/browser   
Application mode: development
Application URL: http://dev.domain.com
Application root: /dev.domain.com/public/dist   abierto
Application start file: server/server.mjs
Custom environment variables: - PORT: 4000

The problem is that I get a 502 Bad Gateway error when I open the app on a browser. Check the log I saw this:

2265912#0: *189198 connect() failed (111: Connection refused) while connecting to upstream

Looks like nginx cannot get to the Node app. On the nginx configuration I have this configuration:

Proxy mode - unchecked
Smart processing of static files - checked
Serve static files directly with nginx - unchecked
Activate nginx cache copy - unchecked
Aditional nginx directives:

Code:
location / {
    proxy_pass http://127.0.0.1:4000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}


location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|eot|ttf|svg|webp)$ {
    root /var/www/vhosts/domain.com/dev.domain.com/public/dist/browser;
    expires 1y;
    access_log off;
    add_header Cache-Control "public";
}

I opened a ssh to the server and I tried starting the Angular SSR application directly with:

node public/dist/server/server.mjs

And everything started working. Using this command:

ss -tuln | grep 4000

I saw the node application running, but when I stop it using Control + C the application didn't show up anymore. If I click on "Restart app" on the Node section of the subdomain, a message appears saying "the application will restart after the first request", but I still get a 502 and using the "ss" command it doesn't show anything working on port 4000.

The Angular SSR app on the server.mjs basically starts an Express server, so any help on setting this up? I have been looking everywhere but the Node documentation for Plesk is almost nothing.

Thanks!
 
Back
Top