django权限错误/admin/字体/机器人-常规-webfont.woff

t5fffqht  于 2023-02-25  发布在  Go
关注(0)|答案(2)|浏览(190)

我得到权限错误。对我的docker容器上的/admin/fonts/Roboto-Regular-webfont.woff的权限被拒绝。我通过命令docker exec -it container /bin/bash进入docker容器并运行curl -XGET 'http://localhost'在我的base.html上的行{% stylesheet 'style' %}上显示错误。docker在aws上的ubuntu机器内。我正在运行这个应用程序与nginx和uwsgi. uid和gid在uwsgi.ini是www-data。请帮助我解决这个问题。
请查找码头日志

root@ip-10-252-14-11:/home/ubuntu/workarea/sourcecode/ntdl/ntdl# docker logs 
ntdl

> ntdl@1.0.2 start-prod /home/ntdl/code
> concurrently --no-color "uwsgi --ini /home/ntdl/code/uwsgi.ini" "nginx" 
 "npm run render-prod"

[0] [uWSGI] getting INI configuration from /home/ntdl/code/uwsgi.ini
[2]
[2] > ntdl@1.0.2 render-prod /home/ntdl/code
[2] > babel-node node/react-render.jsx
[2]
[2] React render server listening at http://0.0.0.0:9009
[2] *****  app. post
[2] Warning: Accessing PropTypes via the main React package is deprecated, 
and will be removed in  React v16.0. Use the latest available v15.* prop- 
types package from npm instead. For info on usage, compatibility, migration 
and more, see 
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []
[2] global ntdl - react render - url http://54.252.92.17/api/search
[2] AJAX Failed: Error: connect ECONNREFUSED 54.252.92.17:80
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []
[2] *****  app. post
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []
[2] global ntdl - react render - url http://54.252.92.17/api/search
[2] AJAX Failed: Error: connect ECONNREFUSED 54.252.92.17:80
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []
[2] *****  app. post
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []  
[2] global ntdl - react render - url http://54.252.92.17/api/search
[2] AJAX Failed: Error: connect ECONNREFUSED 54.252.92.17:80
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []
[2] *****  app. post
[2] advancedFacets - constructor - props [] 
[2] _updateProps []
[2] render advanced Facets - facets []
[2] global ntdl - react render - url http://54.252.92.17/api/search
[2] AJAX Failed: Error: connect ECONNREFUSED 54.252.92.17:80
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []
[2] *****  app. post
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets [] 
[2] global ntdl - react render - url http://54.252.92.17/api/search
[2] AJAX Failed: Error: connect ECONNREFUSED 54.252.92.17:80
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []
[2] *****  app. post
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []
[2] global ntdl - react render - url http://54.252.92.17/api/search
[2] AJAX Failed: Error: connect ECONNREFUSED 54.252.92.17:80
[2] advancedFacets - constructor - props []
[2] _updateProps []
[2] render advanced Facets - facets []

嗨Gasman,你可以看到权限错误实际上roboto字体文件在那个路径是可用的。其次,它在{% stylesheet 'style' %}抛出错误请告诉我会是什么问题。

非常感谢Bharath AK

lyr7nygr

lyr7nygr1#

发生这种情况是因为您(大概)在Amazon S3上托管字体。当从远程域加载字体时,当前浏览器需要有效的CORS HTTP头。
如果您使用的是storages.backends.s3boto.S3BotoStorage后端,则可以通过向设置文件中添加以下行来添加适当的头文件:

AWS_HEADERS = {
    'Access-Control-Allow-Origin': '*'
}

并重新运行./manage.py collectstatic。http://docs.wagtail.io/en/v2.1/advanced_topics/deploying.html#cloud-storage有关详细信息,请访问www.example.com。

a6b3iqyw

a6b3iqyw2#

我的问题发生在用Django应用程序重建Docker图像之后,问题是缺乏对文件/vol/web/static/admin/fonts/Roboto-Bold-webfont.woff的权限。
最后,它是缺乏权限,以整个Docker的命名卷文件夹:

services:
    my_app:
        volumes:
            static_data:/vol/web
...

volumes:
    static_data:

我终于设法让它工作,通过删除卷的挂载目录的内容(以前做备份它,在我的情况下,它位于这里:/var/lib/docker/volumes/my_app_static_data/_data/)并允许Docker重新创建此卷。我不知道这是如何发生的,但我的整个卷目录是由一些奇怪的opc用户和组拥有的,而不是我的常规用户。
可能很简单:

sudo chown my_user:my_user /var/lib/docker/volumes/my_app_static_data/_data

也能完成任务。

相关问题