---
title: "Discussion on \"🚀 Nginx Configuration for Node.js Apps (PM2 + Ubuntu)\" | Hashnode"
description: "Discussion on \"🚀 Nginx Configuration for Node.js Apps (PM2 + Ubuntu)\". personal reference guide for configuring Nginx as a reverse proxy in front of a Node.js application managed by PM2 on Ubuntu."
url: "https://hashnode.com/posts/nginx-configuration-for-nodejs-apps-pm2-ubuntu/69417c7f3da08084203ef52e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [🚀 Nginx Configuration for Node.js Apps (PM2 + Ubuntu)](https://verreauxblack.hashnode.dev/nginx-configuration-for-nodejs-apps-pm2-ubuntu?utm_source=hashnode&utm_medium=feed)

personal reference guide for configuring Nginx as a reverse proxy in front of a Node.js application managed by PM2 on Ubuntu.

Dec 16, 2025 · 3 min read · verreauxblack.hashnode.dev  
Read the article

-   [#nginx](https://hashnode.com/tag/nginx)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#pm2](https://hashnode.com/tag/pm2)
-   [#server](https://hashnode.com/tag/server)
-   [#production](https://hashnode.com/tag/production)

## Written by

[RAJ](https://hashnode.com/@verreauxblack)

@verreauxblack · India

  
[View profile](https://hashnode.com/@verreauxblack)

I'm a Senior Software Engineer @DronaHQ

I am a Senior Software Engineer from India.

## Responses 1

Markdown supported · ⌘↵ to post

[Node Edge Ops](https://hashnode.com/@nodeedgeops)

[Oct 31](https://hashnode.com/posts/nginx-configuration-for-nodejs-apps-pm2-ubuntu/69417c7f3da08084203ef52e/comment/6ae57a82c3d345de1b662f2f)

Good production-oriented nginx front for a PM2-managed Node app. One footgun: put the host once in upstream (or a single proxy\_pass to the cluster port) and let PM2 own worker fan-out — listing every worker port in nginx doubles the surface and breaks affinity assumptions. Forward Host, X-Forwarded-For, and X-Forwarded-Proto so the app sees the public scheme; keep proxy\_read\_timeout and proxy\_send\_timeout above any long request your API actually serves, not the sixty-second default that silently cuts uploads and SSE.

Ops check after reload: hit the Node listen port on localhost, then through nginx, and compare status plus response time. If direct works and the proxy 502s, diff upstream resolution and the forwarded headers before blaming PM2. After pm2 reload, watch for a brief reconnect or 502 spike — that usually means nginx still pointed at a draining worker while the new cluster port was not yet accepting.
