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?
更有益的是,用nginx的反向代理来服务我的角应用程序,或者直接从nginx直接服务?
I would think it would be faster to serve it direcly from nginx.
我想直接从nginx端上来会更快。
3 个解决方案
#1
1
If there is a clean separation of your clientside code and our server side code (eg so anything the client needs to run is either prebuilt into static files or served using your rest api), then it’s far better to serve the clientside 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.
如果有清洁分离clientside代码和服务器端代码(如所以任何客户端需要运行预构建到静态文件或服务使用rest api),然后是更好的服务于clientside文件或者直接从NGINX的CDN。性能和扩展更好,并且在服务器上的代码中管理缓存的工作更少,等等,而且您以后可以独立地扩展api。
#2
2
nginx(as a reverse proxy) + nodejs - It's the best choice.
nginx(作为反向代理)+ nodejs——这是最好的选择。
You will have much more benefits if you choose nginx as a frontend for nodejs. (ssl, http2, configuration, load balancing etc.)
如果你选择nginx作为nodejs的前端,你会得到更多的好处。(ssl、http2、配置、负载均衡等)
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.
如果我们考虑静态文件(js, html,图像)——在一个地方缓存它们更容易(nginx主机配置)节点也可以很好地处理静态文件。
I think that nodejs engine/server should do only one thing and it's business logic of the application.
我认为nodejs引擎/服务器应该只做一件事,它是应用程序的业务逻辑。
#3
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.
根据您的负载需求。可以使用nginx+节点设置多个实例(运行时)。如果您有高负载js应用程序,我建议您使用这个解决方案。否则,这并不重要。
#1
1
If there is a clean separation of your clientside code and our server side code (eg so anything the client needs to run is either prebuilt into static files or served using your rest api), then it’s far better to serve the clientside 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.
如果有清洁分离clientside代码和服务器端代码(如所以任何客户端需要运行预构建到静态文件或服务使用rest api),然后是更好的服务于clientside文件或者直接从NGINX的CDN。性能和扩展更好,并且在服务器上的代码中管理缓存的工作更少,等等,而且您以后可以独立地扩展api。
#2
2
nginx(as a reverse proxy) + nodejs - It's the best choice.
nginx(作为反向代理)+ nodejs——这是最好的选择。
You will have much more benefits if you choose nginx as a frontend for nodejs. (ssl, http2, configuration, load balancing etc.)
如果你选择nginx作为nodejs的前端,你会得到更多的好处。(ssl、http2、配置、负载均衡等)
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.
如果我们考虑静态文件(js, html,图像)——在一个地方缓存它们更容易(nginx主机配置)节点也可以很好地处理静态文件。
I think that nodejs engine/server should do only one thing and it's business logic of the application.
我认为nodejs引擎/服务器应该只做一件事,它是应用程序的业务逻辑。
#3
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.
根据您的负载需求。可以使用nginx+节点设置多个实例(运行时)。如果您有高负载js应用程序,我建议您使用这个解决方案。否则,这并不重要。