I've deployed an Elastic Beanstalk application and it is using nginx instead of Apache. I would really like to have browser image caching working but I can not find anything online about setting the caching headers with nginx. This was much easier with Apache. Any pointers?
Breaking this into two problems.
nginxnginx1. Extending AWS Elastic Beanstalk platform configurations for nginx
Within your application deployment to AWS Elastic Beanstalk, you can include an .ebextensions directory containing configuration files, including nginx related .conf files.
For your scenario, that could look like:
~/my-applicaiton/
|-- .ebextensions
| `-- nginx
| `-- conf.d
| `-- image_caching.conf
You'll want to .zip this along with your deployment bundle ensuring the .ebextensions directory is at the root of the .zip.
Resources:
2. Configuring nginx
Once you've introduced the .ebextensions extension of the existing nginx configuration, you'll be focusing on how nginx can be configured to add the necessary Headers for browser caching to apply to assets.
This other answer may give you more insights on how to configure the location and expiry per asset for nginx.