• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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