Articles in this section

Does Node.js on Plesk support WebSockets (socket.io)?

Plesk for Windows kb: how-to Plesk for Linux ABT: Group B

Applicable to:

  • Plesk for Linux
  • Plesk for Windows

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.

  1. Log into Plesk
  2. Go to Websites & Domains > example.com > Apache & nginx Settings
  3. In the nginx settings section, clear the Proxy mode checkbox

    Note: In case this checkbox is not present, install, or enable nginx.

  4. Click on Apply
On Windows
  1. Log into Plesk
  2. Navigate to Domains > example.com > File Manager
  3. Open the web.config file in the application's document root, and add the following configuration to the <system.webServer> section:

    CONFIG_TEXT: <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

Additional information

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.