1

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/"

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.

davidism
  • 121,510
  • 29
  • 395
  • 339
N.Widds
  • 237
  • 1
  • 3
  • 12
  • Kind of unrelated, but doesn't serving your templates folder as static make the templates (not the actual html) available to anyone on the net? I wonder if that's what you meant to do, and if yes, why? – vlsd Jan 10 '18 at 22:10

1 Answers1

1

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 > > Configuration > Software Configuration > Virtual Path. I needed to change the value of /static/ to static/ here.

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/"
N.Widds
  • 237
  • 1
  • 3
  • 12