Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk12 min

How to Deploy a Node.js and MongoDB App with Rancher on a VPS

Deploy a Node.js and MongoDB application with Rancher on a hardened VPS. This guide covers durable Rancher and MongoDB storage, private service networking, HTTPS ingress, secret handling, safe updates, backups, and recovery.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The dependable pattern is to run Rancher on a hardened Linux VPS, deploy the Node.js application and MongoDB as separate services on a private network, mount persistent storage at MongoDB’s data directory, and publish only the application through an HTTPS ingress or reverse proxy. Rancher’s state must also be mounted to host storage. This arrangement survives container replacement, keeps database traffic private, and gives you a repeatable update and recovery process.

The commands below show a practical single-VPS layout. Adapt image tags, paths, domains, and resource limits to your supported operating-system, Docker, Node.js, MongoDB, and Rancher versions.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand the deployment before you build it

Your VPS is the only physical host, so it contains four logical layers:

  • Host layer: a supported Linux distribution, Docker, firewall, SSH access, updates, and disk storage.
  • Rancher layer: the Rancher server container and its embedded local Kubernetes cluster. Rancher requires privileged container operation for features that run containers inside containers.
  • Application layer: a Node.js workload that listens on an internal port and connects to MongoDB by service name.
  • Data and edge layer: a persistent MongoDB volume, backups, DNS, TLS termination, and an ingress or reverse proxy that exposes only the web application.

MongoDB should not have a public port mapping. Containers on the same private network can reach it at mongo:27017; clients on the internet cannot. The public hostname should terminate TLS at an ingress or proxy and forward requests to the Node.js service.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

A single VPS is simple and economical, but it is also one failure domain. A host failure takes down Rancher, the application, and the database together. Off-host backups are therefore part of the deployment, not an optional enhancement.

Prepare and harden the VPS

Choose supported host software

Select a Linux distribution and Docker release listed as supported by the Rancher version you intend to run. Confirm the support matrix before installation; do not assume that the newest kernel or Docker package is compatible. Size the machine from measured application traffic and MongoDB working-set requirements rather than an invented “minimum” CPU, RAM, or disk number.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reserve fast, durable disk space for both Rancher state and MongoDB data. Leave headroom for image layers, logs, temporary files, database journals, and backups. A full filesystem can stop MongoDB even when the process itself is healthy.

Create an administrative path

Use a non-root administrator with sudo, authenticate SSH with keys, and disable password authentication after confirming key login works. Keep a separate recovery method through your VPS provider. Apply operating-system security updates before exposing any service.

Limit the firewall

Allow SSH only from the addresses that administer the server when possible. Permit web traffic on TCP 80 and 443 only when those ports are required by your certificate or reverse-proxy design. Do not open TCP 27017 to the internet.

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from YOUR_ADMIN_IP to any port 22 proto tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

The command uses a sample firewall syntax for systems that provide UFW. Use the equivalent rules for your distribution’s firewall and verify that you have not locked yourself out.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Point DNS at the host

Create an A record for the public IPv4 address and an AAAA record only when IPv6 is correctly routed and firewalled. Use separate names such as app.example.com and rancher.example.com. Confirm that both names resolve to the intended address before requesting certificates.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Install Rancher with durable state

Rancher’s Docker installation uses an embedded local Kubernetes cluster. Rancher documents privileged mode for the container and requires SSL for secure Rancher communication, including login and cluster interactions. Plan certificate handling before making the administration interface public.

Create a host directory

sudo mkdir -p /opt/rancher
sudo chown root:root /opt/rancher
sudo chmod 700 /opt/rancher

The directory is an example; use a dedicated filesystem or mounted block volume when your VPS offers one. The important property is that /var/lib/rancher is bind-mounted or attached to a durable volume instead of remaining only in the container’s writable layer.

Run the Rancher container

sudo docker run --privileged -d 
  --name rancher 
  --restart=unless-stopped 
  -p 80:80 -p 443:443 
  -v /opt/rancher:/var/lib/rancher 
  rancher/rancher:stable

Use a Rancher tag supported for your operating system and Docker release; pin a tested version for production rather than relying indefinitely on a moving tag. Check startup output with docker logs -f rancher and wait for the server to become ready.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure SSL deliberately

For a public Rancher endpoint, use a certificate from a recognized certificate authority or Rancher’s documented Let’s Encrypt flow. SSL is required by Rancher for secure communication; a self-signed certificate can be useful for an isolated test environment but causes trust and automation problems for a public service.

If a host-level reverse proxy will own ports 80 and 443, map Rancher to private high ports instead, forward the required HTTP, HTTPS, and websocket traffic, and configure the externally visible Rancher hostname consistently. If Rancher itself owns 80 and 443, the application ingress cannot bind those same host ports; use a separate edge listener, address, or proxy arrangement. Decide this before deploying the application.

Build a production Node.js image

Keep the application image reproducible. Pin a Node.js base-image tag that your project supports, install from the lockfile, copy only the files needed at runtime, set NODE_ENV=production, and make the process listen on the container interface rather than only on localhost.

FROM node:22-bookworm-slim
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]

The version in this example is illustrative; use the Node release tested by your application and keep it aligned with your dependency support policy. If your project uses another start command, replace the final line. Your server should bind to 0.0.0.0 and expose a lightweight health endpoint such as /health.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Add a .dockerignore so local dependencies, Git metadata, logs, and environment files are not copied into the image. Build in a controlled environment and scan or review the resulting image before deployment.

Define the web and MongoDB services

The following Compose-style definition expresses the required relationships. Rancher can represent the same design as Kubernetes deployments, services, a persistent volume claim, secrets, and an ingress.

services:
  web:
    build: .
    restart: unless-stopped
    environment:
      NODE_ENV: production
      MONGO_URI: mongodb://root:${MONGO_ROOT_PASSWORD}@mongo:27017/app?authSource=admin
    depends_on:
      - mongo
    expose:
      - "3000"
    networks:
      - private

  mongo:
    image: mongo:${MONGO_IMAGE_TAG}
    restart: unless-stopped
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
    volumes:
      - mongo_data:/data/db
    networks:
      - private

volumes:
  mongo_data:

networks:
  private:
    driver: bridge

Set MONGO_IMAGE_TAG to a tested MongoDB release in a protected deployment environment. The mongo hostname is Docker’s service-discovery name; localhost would point back to the Node.js container and fail. The expose declaration makes the web port available to the private network without publishing it on every host interface.

This example uses the initial root account to keep the wiring visible. Before production, create a least-privilege application user and change MONGO_URI to that account. Keep administrative credentials for maintenance only.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep credentials out of source control

Do not commit passwords, private keys, certificate files, or production environment files to Git. A Compose env_file is convenient for configuration, but an ordinary environment variable is not a strong secret-management system. Docker specifically recommends secrets rather than environment variables for sensitive values such as passwords.

For a small single host, store a protected environment file outside the repository and restrict access:

sudo install -m 600 /dev/null /opt/myapp/.env
sudoedit /opt/myapp/.env

Put the database password and image tag in that file, ensure only the deployment administrator can read it, and rotate credentials when staff, automation, or hosts change. In Rancher’s Kubernetes interface, create a namespace-scoped secret and reference it from the workload instead of displaying the value in a deployment manifest.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Deploy the stack through Rancher

Create an isolated namespace or project

In Rancher, open the local cluster, create a project or namespace for the application, and keep it separate from Rancher’s own system workloads. Apply resource limits and network policies where your cluster configuration supports them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create MongoDB first

Create a persistent volume claim or host-backed volume for /data/db, then create the MongoDB deployment with the root credentials supplied from a secret. Do not add a public service or host-port mapping. A cluster-internal service named mongo gives the Node.js workload a stable DNS name even when the MongoDB pod is recreated.

Create the Node.js workload

Build and publish the application image to a registry that the VPS can authenticate to, or build it on the host if that is your controlled workflow. In Rancher’s workload creation screen, select the image, set NODE_ENV=production, reference the MongoDB secret, set the container port to 3000, and attach the workload to the same namespace and network policy as MongoDB.

Define a readiness check against /health and a liveness check that does not perform destructive database writes. A readiness failure should remove the instance from service while allowing it time to recover; a liveness failure should restart only a genuinely stuck process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add the internal service and ingress

Create a ClusterIP-style service for the web workload. Then create an ingress for app.example.com that terminates TLS and forwards to that service. The ingress is the only application component that needs a public route. Do not create an ingress, NodePort, or load-balancer service for MongoDB.

If you are using a Compose-compatible Rancher workflow instead of Kubernetes resources, preserve the same boundaries: both services join one private network, MongoDB has only an internal address, and the edge proxy forwards to the web service.

Make MongoDB data survive container replacement

MongoDB writes its database files under /data/db in the official container layout. Attach a named volume, host-backed volume, or Kubernetes persistent volume claim at that exact path. Docker volumes are managed independently of a container, so removing and recreating the MongoDB container does not remove the volume unless you explicitly delete it.

Verify the mount before trusting it:

docker inspect mongo --format '{{json .Mounts}}'
docker volume ls

In Rancher, inspect the workload’s volume attachment and confirm that the claim is bound to the intended disk. Test a write and read from the application, then recreate only the MongoDB container in a maintenance window and confirm that the record remains.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Back up off-host

A persistent volume protects against container replacement, not disk failure, ransomware, operator error, or loss of the VPS. Schedule database-aware backups to storage outside the host, retain multiple restore points, and encrypt them. Back up Rancher’s /var/lib/rancher state as well so that the management plane can be recovered alongside application definitions.

Perform a restoration exercise on a separate environment. A backup that has never been restored is an assumption, not a recovery plan.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Publish the application over HTTPS

Use one public edge path for the application. The edge terminates TLS for app.example.com, redirects HTTP to HTTPS, and proxies to the internal Node.js service. Obtain a certificate from a recognized authority or use the documented certificate-automation flow for your ingress.

Forward the headers your framework needs, including the original host and protocol, and configure the Node.js framework to trust the proxy according to its security guidance. Set websocket and request-timeout options if the application uses long-lived connections. Keep MongoDB off the edge entirely.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Rancher itself also needs secure access. Give the Rancher administration hostname its own certificate and route. On a single IP, use one front proxy that dispatches by hostname, or place Rancher and the application on distinct externally reachable listeners. Avoid trying to bind two independent services to the same host ports.

Verify the deployment before calling it live

  1. Resolve the application and Rancher DNS names and confirm they point to the intended VPS.
  2. Open the Rancher URL over HTTPS and verify that the certificate hostname matches.
  3. Check that the Node.js health endpoint returns success through the public application hostname.
  4. Execute a real database write and read through the application, then confirm the record exists in MongoDB.
  5. From the VPS, verify that no public firewall rule or published port exposes 27017.
  6. Inspect Rancher events, workload status, container logs, and restart counts.
  7. Restart or recreate the web container and confirm that it reconnects to MongoDB without data loss.
  8. Restore a recent backup in an isolated environment and document the elapsed recovery time.

Common failures and fixes

  • Connection refused to MongoDB: check that the URI host is mongo, not localhost; verify both services share a network and that MongoDB is ready.
  • Authentication failed: compare the secret value, username, and authSource=admin; remember that initialization variables affect a newly initialized data directory and do not overwrite an existing database.
  • Data disappeared: inspect the MongoDB mount and confirm that the volume was not removed. Restore from an off-host backup if the data directory was deleted.
  • HTTPS shows the wrong certificate: check DNS, ingress host rules, certificate secret selection, and whether another process owns ports 80 or 443.
  • Rancher repeatedly restarts: inspect docker logs rancher, verify privileged mode, confirm available disk space, and ensure /var/lib/rancher is writable and persistent.
  • The app works inside the container but not publicly: make the Node.js server listen on 0.0.0.0, confirm the service target port, and inspect ingress or proxy access logs.

Update the application without touching the database

Build and deploy the web image independently. With a Compose-style deployment, Docker’s production update pattern is:

docker compose build web
docker compose up --no-deps -d web

The --no-deps option prevents an application release from needlessly recreating MongoDB. In Rancher’s Kubernetes interface, update the web workload image and allow a rolling replacement; keep the MongoDB workload and persistent volume unchanged.

After deployment, check the health endpoint, application logs, database connectivity, and error rate. If the new image fails, roll the web workload back to the previous known-good image. Treat database schema changes separately: use backward-compatible migrations, take a backup first, and never assume that rolling back application code automatically reverses a migration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Operate the single-VPS system

  • Use restart policies, but do not mistake automatic restarts for health monitoring.
  • Alert on disk consumption, MongoDB health, repeated container restarts, certificate expiry, and backup failures.
  • Retain and rotate logs so they cannot fill the same filesystem that stores the database.
  • Patch the host, Rancher, base images, Node.js dependencies, and MongoDB image on a planned schedule.
  • Use production-specific Compose overrides or Rancher configuration for ports, secrets, restart policy, and other deployment settings rather than changing development files in place.
  • Document DNS, firewall rules, volume locations, credentials-rotation procedures, backup destinations, and rollback commands.
  • Test recovery after major upgrades and whenever storage, certificates, or the host operating system changes.

Know when one VPS is no longer enough

Approach Operational simplicity Failure domain Scaling and recovery Database topology
Rancher on one VPS Lowest complexity and cost; one host to patch Application, control plane, and database share one host Vertical scaling and tested backups; recovery requires restoring the host or workloads Single MongoDB instance unless you design replication separately
Multiple Kubernetes nodes More networking, storage, upgrades, and observability work Can tolerate a node failure when designed correctly Horizontal scheduling and more elaborate recovery options Requires an intentionally designed replica set and durable shared or replicated storage
Managed MongoDB with VPS application Less database administration; additional service dependency Database provider and network become separate dependencies Provider may offer managed backups and scaling; verify its terms directly Topology, backup retention, and availability depend on the selected service

The single-node design is appropriate when simplicity and cost matter more than host-level high availability. Move to multiple nodes or a managed database when downtime, recovery objectives, storage growth, or traffic patterns justify the added operational complexity. No current price or service-level comparison is implied by these architectural choices.

Final deployment checklist

  • Supported Linux and Docker versions are installed and patched.
  • SSH is restricted, a non-root administrator exists, and firewall rules allow only required ports.
  • DNS records resolve correctly for Rancher and the application.
  • Rancher runs privileged, uses SSL, and persists /var/lib/rancher.
  • The Node.js image uses a tested, pinned runtime and production dependencies.
  • Node.js and MongoDB share a private network; the URI uses mongo, never localhost.
  • MongoDB mounts durable storage at /data/db and has no public port.
  • Passwords are stored as protected secrets, not committed to Git.
  • Ingress or a reverse proxy publishes only the Node.js application over HTTPS.
  • Health checks, logs, off-host backups, restoration tests, and rollback steps are documented.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.