【问题标题】:compress.js made the CACHE directoly under uwsgi not nginxcompress.js 直接在 uwsgi 下而不是 nginx 下制作 CACHE
【发布时间】:2022-02-15 14:56:27
【问题描述】:

我在nginxuwsgi上使用Django Compressor

我有 nginxuwsgi 的每个 docker 容器

我提前将静态文件夹复制到nginx:/static,其他复制到uwsgi:/myapp/

但是compress.js动态压缩文件并设置在uwsgi容器的uwsgi:myapp/static/CACHE下。

<script src="/static/CACHE/js/output.b6723c2174c0.js">

因此没有找到这个文件的 404,因为这个请求被重定向到 nginx:/static 而不是uwsgi:/myapp/static

有人如何解决这个问题?

我的 nginx 设置如下

server {
    listen      8000;
    server_name 127.0.0.1;
    charset     utf-8;

    location /static {
        alias /static;
    }

    location / {
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/.htpasswd;
        proxy_pass  http://uwsgi:8001/;
        include     /etc/nginx/uwsgi_params;
    }
}

【问题讨论】:

  • 你好白熊。你解决了吗?

标签: javascript django nginx


【解决方案1】:

这是关于故障排除的。可能有不同的问题。 类似的报道在这里django-compressor and nginx: 404 with compressed files

遇到同样的问题,我发现在 settings.py 中 COMPRESS_ROOT 被定义为 Nginx 配置中未指定的路径。 删除 COMPRESS_ROOT 修复了它。参考:Django Compressor Quickstart

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-29
    • 1970-01-01
    • 2011-12-30
    • 1970-01-01
    • 2017-08-07
    • 2012-12-05
    • 1970-01-01
    相关资源
    最近更新 更多