7

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.

2
  • Thanx for the replies everyone it was really helpfull, I'm going to serve angular directly from nginx and use a reverse proxy to node for api calls. This is a better seperation of concerns. Commented Nov 8, 2017 at 14:28
  • I am surprised there are so few upvotes on this question. I think it is very relevant. Commented Jan 7, 2018 at 14:45

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

5 Comments

But if I serve angular via node the request would still go through nginx?
Yes of course. nginx uses 80/443 port each request to these ports will be handled by nginx. It's a problem?
Yeah but it would still leverage ssl, http2 etc, but what I want to know is serve angular from node or directly from nginx
The question was should he serve the front end files from NGINX directly or from a Node app sitting behind an NGINX proxy. Your answer explains why NGINX is good, not why the combination is good for serving the static angularjs files.
Directly from nginx it works perfectly with static files.
0

Depending on your load requirements. You can setup multiple instances(runtimes) using nginx+node. If you have high load js application, i would suggest going for this solution. Otherwise, this does not matter.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.