'Should Frontend static files has its own container with Nginx or combined inside reverse proxy container
I have a:
- Frontend - Angular SPA that has been compiled to static assets
- Backend - ExpressJS server working as my backend API
- Reverse proxy using Nginx to either direct to the frontend or backend
I'm also planning to containerize these components using Docker. Now my question is, should the frontend has its own container with Nginx as web server, or should it be combined inside the reverse proxy container?
The former seems ideal because there's more encapsulation as the frontend stuff is not mixed up with the reverse proxy (which should just direct traffic), but I'm not sure if it adds additional overhead because the request now goes from reverse proxy -> FE web server. Meanwhile, if the FE is directly inside the reverse proxy container, then the reverse proxy can directly find it in its own filesystem.
Which one is the best practice for serving FE static files?
Solution 1:[1]
only a few years experienced but from my point of view it would be great to have those in different container then maybe add caching policy inside your reverse proxy this way the common request would end up being served quickly without requesting FE webserver.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SCcagg5 |
