简体   繁体   中英

elastic beanstalk - app is returning 403 not found error for static files

Deploying a Django app to Beanstalk this week for the first time and I successfully deployed the app, however some of the static files are returning a 403 forbidden error. I'm using Django Rest Framework which is installed as dependency. Most of the static files that are 403-ing are from the Django Rest package.

here is what i am seeing in the log

[Wed Mar 16 18:37:03.034730 2016] [authz_core:error] [pid 8842] [client 172.31.40.112:57965] AH01630: client denied by server configuration: /static, referer: {APPURL}.elasticbeanstalk.com/

my static properties in settings.py:

 STATIC_URL = '/static/'

django.config

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: hungryapp/wsgi.py   
  aws:elasticbeanstalk:container:python:staticfiles:
    /static/: /static/  

In django, you can group all the static files from different directories, which you specify in the STATICFILES_DIRS variable.

There is a command called python manage.py collectstatic , that does the above job of copying all the static files in STATICFILES_DIRS, and also the static files related to the admin panel, and in this case, your Rest Framework related static files. All the static files are copied to a directory which you would have mentioned as STATIC_ROOT in your django settings file.

Now 2 things have to be made sure by you:

1) You run the python manage.py collectstatic command
2) Do a chmod -R 777 /path/to/static_root

You get 403 because the web server cannot access your static file, since it is denied the permission to read the file. Doing a chmod 777 gives the permission to read (and write and execute ) the static file, which should clear your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM