Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use both Nginx AND HAProxy for production node app?

I have a node/express/postgres app. I have the postgres db on one node and I plan to have several application nodes behind a separate load balancer so I can scale horizontally.

I set up my application nodes to each run nginx in front of the node app. So I have nginx listening on port 80 and forwarding the web requests to the node app on the same box which is listening on port 3000.

Then I was planning to put HAProxy in the front to handle the SSL termination and load balancing across the application nodes

My question: Is nginx obsolete in this case? Would it be better to just have HAProxy just forward to the application nodes on port 3000?

Are there any benefits of having nginx on each of the application nodes? I wont be serving any static files. My node app is a REST api that only returns JSON data. The node app doesn't ever render or serve any html.

like image 963
nmajor Avatar asked Sep 16 '25 01:09

nmajor


1 Answers

I would just use HAProxy to proxy to the application nodes.

Having Nginx would be adding another potential point of failure and HAProxy has to health check both Nginx and node.js to ensure they are healthly.

like image 138
Tan Hong Tat Avatar answered Sep 18 '25 17:09

Tan Hong Tat