Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serve angular in node vs nginx

just a quick question.

What would be more beneficial, serving my angular application via node with a reverse proxy from nginx or just serving it directly from nginx?

I would think it would be faster to serve it direcly from nginx.

like image 950
Hein Avatar asked Nov 08 '17 13:11

Hein


2 Answers

If there is a clean separation of your client-side code and your server side code (e.g so anything the client needs to run is either pre-built into static files or served using your rest api), then it's far better to serve the client-side files either directly from NGINX or from a CDN. Performance and scaling are better, and there is less work for you to do in code on the server to manage caching, etc. plus you can later scale the api independently.

like image 188
Paul Avatar answered Oct 21 '22 00:10

Paul


nginx(as a reverse proxy) + nodejs - It's the best choice.

You will have much more benefits if you choose nginx as a frontend for nodejs. (ssl, http2, configuration, load balancing etc.)

If we think about static files (js, html, images) - it's more easier to cache them in one place (nginx host config) node also works with static file quite good.

I think that nodejs engine/server should do only one thing and it's business logic of the application.

like image 23
RDK Avatar answered Oct 20 '22 23:10

RDK