Amazon elastic beanstalk elasticbeanstalk赢得';不设置虚拟路径
我正在尝试新的AWS Elastic Beanstalk控制台ui。我现在在ui上设置虚拟路径时遇到问题 基本上,我将所有静态文件(包括index.html)放在捆绑包中的Amazon elastic beanstalk elasticbeanstalk赢得';不设置虚拟路径,amazon-elastic-beanstalk,Amazon Elastic Beanstalk,我正在尝试新的AWS Elastic Beanstalk控制台ui。我现在在ui上设置虚拟路径时遇到问题 基本上,我将所有静态文件(包括index.html)放在捆绑包中的ui文件夹中 这是捆绑结构: /ui /ui/favicon.ico /ui/index.html /ui/static /ui/static/css/... /ui/static/js/... /ui/static/media/... package.json yarn.lock app.js // this is the
ui
文件夹中
这是捆绑结构:
/ui
/ui/favicon.ico
/ui/index.html
/ui/static
/ui/static/css/...
/ui/static/js/...
/ui/static/media/...
package.json
yarn.lock
app.js // this is the node api and it works
API在访问my[]时起作用。我的目的是设置虚拟目录以服务于捆绑文件夹ui中的静态文件
当节点api与任何内容都不匹配时,它会向下发送index.html
。这样做:[我得到index.html
然后浏览器请求静态文件/static/js/main[hash].js
。这是可行的,但问题是我甚至无法设置任何虚拟路径来播放。我需要将浏览器请求/static
映射到AWS的/ui/static
elasticbeanstalk错误:
/static/:无效的选项规范(命名空间:“aws:elasticbeanstalk:container:python:staticfiles”,OptionName:“/static/”):未知的配置设置。
static/:无效的选项规范(命名空间:“aws:elasticbeanstalk:container:python:staticfiles”,选项名称:“static/”):未知的配置设置。
/资产:无效的选项规范(命名空间:“aws:elasticbeanstalk:container:python:staticfiles”,选项名称:“/assets”):未知的配置设置。
静态:无效的选项规范(命名空间:“aws:elasticbeanstalk:container:python:staticfiles”,选项名称:“static”):未知的配置设置
无论我把斜杠放在哪里,它都不会起作用:
我指定的所有路径都存在于我部署的应用程序包中,除了用于尝试任何不同内容的/static/assets
我不确定这是否是新UI上的错误。如果有人有相同的问题,请告诉我。我在尝试使用Amazon Linux 2从Python 3.7Django应用程序提供静态内容时发现了这个问题;但是,我认为对于不同的平台,答案是相同的 阅读文档时,我发现了以下链接: 它指示了一个类似这样的
.config
示例文件
示例.ebextensions/static files.config
option_settings:
aws:elasticbeanstalk:environment:proxy:staticfiles:
/html: statichtml <-- path/to/your/static/dir/ (added by Nick)
/images: staticimages
选项设置:
aws:elasticbeanstalk:environment:proxy:staticfiles:
/html:statichtml仅详细说明Nick的答案-此处的/html
或/images
将对应于您的环境预期接收文件的路径
因此,如果打开浏览器控制台的“网络”选项卡,会看到如下内容:
404获取http://your.app.com/static/admin/css/base.css
那么您可能希望路径是/static
而不是/html
值statichtml
将对应于eb实例上静态文件的位置
因此,如果运行eb ssh
,然后运行manage.py collectstatic
,并获得如下输出:
You have requested to collect static files at the destination
location as specified in your settings:
/var/app/current/static
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
那么您可能希望值为/static/
没关系。我将在单独的步骤中将web静态文件部署到S3。缺点是我必须对API进行跨域API调用。这可能是一个更好的结构。我在这里描述了完全相同的问题,如果有人愿意,我仍然对答案感兴趣有一个。这可能会有所帮助:我在Node.js EBS上找到了关于这个问题的答案