Using Node.js with ISPConfig on a VPS

Procédure

To run a Node.js application on your VPS with ISPConfig, you need to configure Apache as a reverse proxy to the local port of your script. Node.js is a server-side JavaScript runtime that makes it possible to create fast and scalable web applications. By combining a process manager such as PM2 with ISPConfig directives, you ensure service persistence and SSL certificate security.

The steps

  1. Access your VPS management

    Log in to your customer area, go to the Servers section, then click Manage next to your VPS machine under ISPConfig.

    Using Node.js with ISPConfig on a VPS
  2. Open the ISPConfig interface

    In your server dashboard, click Administration Panel to connect to the ISPConfig console.

    Using Node.js with ISPConfig on a VPS
  3. Manage managed service and root access if necessary

    If you choose to install Node.js globally for the whole system rather than for the site's local account, click Managed service, check the Server NOT managed by LWS option, and confirm with Validate. LWS will then no longer manage the server, which unlocks the credentials in ROOT SSH Access.

    Using Node.js with ISPConfig on a VPS
  4. Create the website and enable the SSL certificate

    In ISPConfig, open the Sites tab, add your domain (for example "example.fr"), then check the SSL and Let's Encrypt SSL boxes before saving.

  5. Connect to the server via SSH

    Open your terminal and establish the SSH connection with your account (ISPConfig site user or root user if managed service has been removed).

    Using Node.js with ISPConfig on a VPS
  6. Enable Apache proxy modules

    To redirect HTTP traffic to your application, enable the required modules with the a2enmod proxy proxy_http command, then restart Apache via systemctl restart apache2 (an action requiring administrative rights or already active depending on your plan).

  7. Install Node.js LTS

    Install the LTS version of Node.js on your session using nvm or your distribution's repositories, then verify the installed version by entering the node -v command.

  8. Create the minimal Express application

    Go to your website directory, initialize a project with npm init -y, install the Express framework with npm install express, and create a server.js file configured to listen on local port 3000.

  9. Start and keep the application running with PM2

    PM2 is a process manager for Node.js that keeps applications running continuously and restarts them after an incident. Install it with npm install -g pm2, start your script via pm2 start server.js --name mon-app, and save the state with pm2 save.

  10. Configure Apache reverse proxy in ISPConfig

    A reverse proxy is an intermediary server that receives visitors' web requests and forwards them to the internal application server. In ISPConfig, edit your site, go to the Options tab, then add the following in the Apache Directives field: ProxyPreserveHost On followed by ProxyPass / http://localhost:3000/ and ProxyPassReverse / http://localhost:3000/.

  11. Test operation over HTTPS

    Open your browser and enter your site's address (for example https://example.fr) to see your secure Node.js script displayed.

Node.js installation methods on your VPS

Several approaches are possible for integrating Node.js packages according to your administration requirements and the maintenance of your managed service.

  • Installation via NVM (Node Version Manager) — Allows you to install and manage multiple versions of Node.js directly in the user directory, without root privileges and without changing the VPS managed service.
  • Installation via Debian's APT package manager — Installs a stable global version for the entire operating system, requiring root rights and disabling managed service.

Frequently asked questions

Why is my site showing a 502 or 503 error?

A 502 Bad Gateway or 503 Service Unavailable error indicates that Apache cannot reach Node.js on the configured port. Check that your application is properly started under PM2 with the pm2 status command and that it is indeed listening on local port 3000.

Is LWS managed service mandatory for Node.js to work?

No. The ISPConfig VPS is managed by default, which ensures support for your server. You can run Node.js without root thanks to nvm under your site's shell account. If you remove managed service to get root access, you are responsible for the full administration of the server yourself.

Will my Node.js application restart if the VPS is rebooted?

Yes, provided you have run the pm2 startup command and then pm2 save. PM2 automatically reactivates your scripts when the system starts.

Can I run multiple Node.js applications on the same server?

Yes. Simply assign a different local port to each application (for example 3000, 3001) and configure the corresponding Apache ProxyPass directives for each domain in ISPConfig.

Do I need to open my application's port in the firewall?

No. The Node.js application listens only on the local address (203.0.113.10 or localhost). Apache is the server that receives secure web connections on the standard ports 80 and 443 and redirects them internally.

Useful links

help.lws.net/a/7952
Was this article helpful?

Yes

No

Read 3 times

Thank you! Feel free to ask questions about our documentation if you would like more information, and help us improve it.

Similar articles

A question about this article?

Ask the LWS team and the community. Answers are published after moderation.

Ask the LWS team and its community a question

GDPR: Controller: LWS-Ligne Web Services. Purpose: moderation and public publication of your question, possible notification of an answer. Legal basis: consent (Art. 6(1)(a) GDPR). Email retention: 90 days after notification, 12 months maximum without an answer. To exercise your rights, see the GDPR section of our Terms and Conditions.