Elastic Beanstalk静态文件夹403错误 [英] Elastic Beanstalk Static Folder 403 Error

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

问题描述

我在尝试解决Elastic Beanstalk Flask应用程序中的"403 Forbidden"错误时遇到了困难.我已经按如下所示设置了我的python.config文件:

I'm stuck trying to solve a "403 Forbidden" error in my Elastic Beanstalk Flask application. I have set up my python.config file as below:

option_settings:
  aws:elasticbeanstalk:container:python:staticfiles:
    "/static/": "/static/"
    "/templates/": "/templates/"


commands:
  01_set_file_permissions:
    command: "chmod 777 /opt/python/current/app/static/"

静态文件夹最初提供的是404,但是python.config的静态文件部分修复了该问题.我的问题是我无法在服务器上识别文件权限.它总是返回403错误.请帮忙.

The static folder was initially giving a 404 but the static files section of python.config fixed that. My problem is I can't get the file permissions to be recognised on the server. It always returns a 403 error. Please help.

推荐答案

我已解决此问题.option_settings部分不正确,因为未提供到文件夹的路由作为相对路径.此外,/static/文件夹已经通过AWS控制台中的硬编码值进行了设置:

I worked out the fix. The option_settings section was incorrect in that the route to folder was not given as a relative path. Also the /static/ folder was already set via a hard-coded value in the AWS console at:

AWS> Elastic Beanstalk>>配置>软件配置>虚拟路径.我需要在此处将/static/的值更改为static/.

AWS > Elastic Beanstalk > > Configuration > Software Configuration > Virtual Path. I needed to change the value of /static/ to static/ here.

最后,根本不需要命令部分.固定的python.config文件(有效)如下:

Finally the commands section was not required at all. The fixed python.config file (that works) is as follows:

option_settings:
  aws:elasticbeanstalk:container:python:staticfiles:
  "/templates/": "templates/"

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

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