WebGee Docsالتوثيق
WordPress Cloud

Deploy a Node.js application

Run a Node.js app alongside or instead of PHP, started automatically and proxied by the web server at a path you choose.

WordPress Cloud can run a Node.js application in the same container as your website, with the web server forwarding traffic to it. Applies to all WordPress Cloud packages.

Go to AdvancedNode.js.

The Node.js page before any application is defined

Select Deploy app.

Choose how it starts

The Deploy Node.js form, showing the automatic and manual modes

Automatic (Production) — the platform starts your application and restarts it if it exits. Use this for anything live.

Manual (Development) — the application is proxied but not started for you. Initialise the Node environment yourself over SSH:

/usr/bin/install_nvm_and_node.sh

Then start the process when you want it. Useful while you are iterating, because the platform will not restart a process you deliberately stopped.

Configure it

FieldNotes
Node versionstable by default; pin a specific version if your app needs one
Startup commandFor example npm start
Working directoryThe directory to change into first. Leave blank for the home directory

Configure the proxy

The proxy section, with path, port and web socket options

Proxy enabled is on by default, and forwards traffic from your primary domain to the application.

  • Path — leave blank to proxy the whole site, or enter a path such as api to proxy only example.com/api. Leave it blank only if Node is serving everything; on a site that also runs WordPress, use a path.
  • Port3000 by default. Your application must listen on 0.0.0.0 on this port, not on 127.0.0.1, or the proxy cannot reach it.
  • Allow web socket proxy upgrade — tick this if your application uses WebSockets. Without it, the upgrade request is not passed through and the connection silently falls back or fails.

Select Deploy.

Verify

  • The path you proxied returns your application rather than a 502.
  • Restarting the container leaves the application running, if you chose Automatic.
  • WebSocket features connect, if you enabled the upgrade.

On this page