Elastic Beanstalk Nginx Serve Static Files

﹥>﹥吖頭↗ 提交于 2019-12-03 16:46:23
Kashif Zaidi

This is a known bug, They only support python when it comes to the web console. if your application is in nodejs you would need to set these properties from the cli.

you can setup the values from cli this way

aws elasticbeanstalk update-environment --environment-id your_enviornment_id --option-settings 'Namespace=aws:elasticbeanstalk:container:nodejs:staticfiles,OptionName=/assets,Value=/static/assets'

or editing the config file from eb config.

Kashif Zaidi's answer works well, but if you want to keep the setting consistent across multiple deployments, you can make a .ebextensions directory at the project root with some file like 01_environment_settings.config that specifies that setting like so:

option_settings:
  aws:elasticbeanstalk:container:nodejs:staticfiles:
    "/assets": "/static/assets"

You can specify multiple static file settings, for example:

option_settings:
  aws:elasticbeanstalk:container:nodejs:staticfiles:
    "/app/": "frontend_build/"
    "/static/": "frontend_build/static/"
    "/backend_static": "static/"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!