We have a Node.js/Express application that is deployed as Docker containers into AWS ECS. This app has a few static resources (CSS, JS), and I would like requests for these assets to bypass Node.js and be served directly by Nginx for performance reasons.
Currently, we have docker-compose starting an Nginx container, and Nginx is configured with a proxy_pass rule for proxying and caching static resources from the Node container like this:
location /static {
proxy_cache STATIC;
proxy_pass http://nodejs;
}
The problem with this approach is that the first request for any static asset is still served by Node.js, and only then cached by Nginx.
I would like to by-pass Node.js entirely for these assets.
a) What is a better approach to achieve this goal?
b) I thought of using volumes
, but in the context of ECS, if we do this and have multiple containers all deployed to the same AWS host (e.g. multiple copies of the Node, Nginx containers running in same EC2 instance), will this cause problems since they're all trying to mount the same directory in the filesystem?
Any guidance will be greatly appreciated, since we haven't been able to find any best-practice approach on how to handle this situation. Thanks.