Elastic Beanstalk Nginx 服务静态文件 [英] Elastic Beanstalk Nginx Serve Static Files

查看:22
本文介绍了Elastic Beanstalk Nginx 服务静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Elastic Beanstalk 的新手,尝试为 Node.js Express 应用程序提供服务,并利用 Nginx 单独提供我们的静态文件.我遇到的所有教程都没有明确说明如何定义虚拟路径.

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 explicit in how to define the virtual path.

我正在尝试通过浏览器中的 AWS 控制台执行此操作.我正在尝试为静态文件添加虚拟路径/目录设置.在控制台中,我在
Elastic Beanstalk >我的应用程序>配置>静态文件

I'm attempting to do this through the AWS console in the browser. I am trying to add a virtual path/directory setup for the static files. In the console I'm at
Elastic Beanstalk > myapp > configuration > Static Files

但是无论我在这里添加什么,我都会收到此错误消息:

But no matter what I add here I get this error message:

我还尝试添加完整目录路径 (/var/app/current/dist/public/images/).我需要添加另一个 .ebextensions/*.conf 文件吗?我对 Nginx 没有太多经验,所以如果修复是一个 .conf 文件,我将不知道它是什么

I've also tried adding the full directory path (/var/app/current/dist/public/images/). Is there another .ebextensions/*.conf file I need to add? I don't have a lot of experience with Nginx so if the fix is a .conf file I wouldn't know what it is

推荐答案

这是一个已知的错误,当涉及到 web 控制台时,他们只支持 python.如果您的应用程序在 nodejs 中,则需要从 cli 设置这些属性.

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.

您可以通过这种方式从 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'

或从 eb config 编辑配置文件.

or editing the config file from eb config.

这篇关于Elastic Beanstalk Nginx 服务静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆