Elastic Beanstalk Nginx Serve Static Files

后端 未结 2 1312
天命终不由人
天命终不由人 2020-12-31 20:42

I am new to Elastic Beanstalk, trying to serve a Node.js Express app and utilize serving our static files separately with Nginx. None of the tutorials I\'ve come across are

相关标签:
2条回答
  • 2020-12-31 21:09

    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/"
    
    0 讨论(0)
  • 2020-12-31 21:30

    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.

    0 讨论(0)
提交回复
热议问题