Nginx is throwing an 403 Forbidden on Static Files

后端 未结 6 1744
野性不改
野性不改 2020-12-14 19:10

I have a django app, python 2.7 with gunicorn and nginx.

Nginx is throwing a 403 Forbidden Error, if I try to view anything in my static fo

6条回答
  •  别那么骄傲
    2020-12-14 19:18

    It seems the web server user doesn't have read permissions to the static files. You can solve this in 2 ways:

    1. (easiest, safer) run the nginx as you app user instead of default nginx user. To do this, add the following in nginx.conf

      user your_app_user
      

      Replace your_app_user with appropriate unix username for your app. In this case the your_app_user already has necessary permissions to the static content.

    2. Another way would be to to grant permissions for the web server user to the static dir.

提交回复
热议问题