Question
Does Node.js and Ruby on Plesk support WebSockets (socket.io)?
How to provide WebSockets feature to customers?
Answer
Plesk itself does not forbid to use WebSockets, it only provides runtime environment to run Node.js and Ruby using Phusion Passenger, or iisnode.
The rest depends on particular website code design/implementation details.
On Linux
Note: Websockets work properly only if nginx-only web hosting is configured (with Proxy mode disabled) due to the following Apache module issue: WebSockets don't work on Apache.
-
Go to Websites & Domains > example.com > Apache & nginx Settings
-
In the nginx settings section, clear the Proxy mode checkbox
Note: In case this checkbox is not present, install, or enable nginx.
-
Click on Apply
On Windows
-
Navigate to Domains > example.com > File Manager
-
Open the
web.config
file in the application's document root, and add the following configuration to the <system.webServer> section:<rewrite>
<rules>
<rule name="SocketIO" patternSyntax="ECMAScript">
<match url="socket.io.+" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>Note: In case <rewrite> section already exists in the configuration file, instead add the <rule> part to the existing <rules>
The sample "Phusion Passenger: Node.js WebSocket demo" application can be used to verify whether WebSocket connections are working fine on the webserver: https://github.com/phusion/passenger-nodejs-websocket-demo