1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
This guide explains how to use Node.js with a managed Cloud Server.
To install Node.js via NVM:
List the available versions:
Then, to install a specific version:
Or to install the latest version:
nvm install node
Change the Node.js version, to set to version 6.3.1 (or another version):
Go to your cloud server's WebSSH console to set up NVM on your cloud server.
You need to source the .profile file :
You can then run the command :
Redirect web traffic to a specific port
By default, on the Cloud, web traffic is sent to Apache. To send requests to a Node script or other service (as long as it is "listening" on a port between 4000 and 4009), it needs to go via HAProxy.
This applies in particular to Express servers, Socket.IO, Meteor.js, Nuxt.js, Django, Flask, Ruby on Rails, even possibly Java (J2E), etc.
To do this, you need to ensure that the service is listening on a port between 4000 and 4009 (in particular using
server.listen(4000) for Express or a basic HTTP Node server, or by other means depending on the type of project such as a configuration file, in the code etc.) and on all interfaces (0.0.0.0). You will also need to configure HAProxy as in the following example:
- Log in to your Infomaniak Manager (manager.infomaniak.com)
- Go to Cloud server
- Click on the Cloud server concerned
- From the left side panel, click on FastInstaller
- From the applications list, click on the icon on the far right of FastInstaller and select Configure
Configure Node as a service
To configure Node as a service, we recommend using a "service systemd-user".