• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Resolved Basic Guide for using NGINX with Web-Sockets

Max5593

New Pleskian
Hi,

after 2 days of research i didnt find any working solution to get access to my Nodejs Websocket server.

My Setup:
Nodejs Server with a regular API, listening on assigned Port (i.e. 33333) - everything works fine, every request goes through

On that same nodejs Server i also run a socket.io API which runs on another port (i.e. 22222). Concerning this Socket API i have no clue how to define the NGINX Plesk configuration.

Could somebody write down basic steps how to setup the NGINX Socket Conf?
Is it even possible to use sw-nginx (custom Plesk nginx version) with WebSockets?

Greetings Max
 

I also tried adding a location directive. It looks like the following:


==> This is the socket api
location /api1/ {
proxy_pass http://localhost:62646/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}

==> This is the other classic and working api
location /api2/ {
proxy_pass http://localhost:62233/;
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;
}

The big problem: The socket.io polling request displays error message 404 - Not found.
When i open the socket connect Url (http://myPleskDomainname/api1/) in my Browser it even displays the error response of my working api. Looks like there is a redirect to api2
 
Last edited:
Back
Top