【问题标题】:running flower behind a reverse proxy在反向代理后面运行花
【发布时间】:2018-08-21 04:15:51
【问题描述】:

以下是我的 nginx 配置:

    location /flower/ {
    rewrite /flower/(.*) /$1  break;

    sub_filter '="/' '="/flower/';
    sub_filter_last_modified on;
    sub_filter_once off;

    proxy_pass http://localhost:5555/;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

location /flower/static/ {
    sub_filter '/api' '/flower/api';
    sub_filter "'/monitor" "'/flower/monitor";
    sub_filter "'/worker" "'/flower/worker";
    sub_filter "'/'" "'/flower/'";
    sub_filter "'/dashboard'" "'/flower/dashboard'";
    sub_filter '"/update-dashboard"' '"/flower/update-dashboard"';
    sub_filter_types application/javascript;  # by default, sub_filter won't touch JS
    sub_filter_last_modified on;
    sub_filter_once off;

    alias <VIRTUALENV_PATH>/python3.4/site-packages/flower/static/;
    expires 30d;
}

以上链接:https://github.com/mher/flower/issues/414

我的花版本是0.9.2,nginx版本是1.12.1

我跑花如下:

$celery flower -A project_name --port=5555 --broker redis://broker_url:port

这会呈现以下内容:

我按如下方式运行flower:(使用--url_prefix=flower)

$ celery flower -A project_name --port=5555 --broker redis://broker_url:port --url_prefix=flower

然后渲染所有静态文件,如下所示:

当我单击上面的任何选项卡(例如任务)时,会出现问题,如下所示:

我注意到 url 而不是说:/flower/dashboard/ 是 /flower/flower/dashboard 等等。

我在这里缺少什么? nginx 配置有什么要改的吗?

【问题讨论】:

    标签: python python-3.x nginx celery flower


    【解决方案1】:

    我不确定你为什么在你的 nginx 配置中使用sub_filter

    在我看来,您在 xyz.com/flower 这样的特定 URL 中托管花,这就是您使用 sub_filter 的原因。

    虽然我没有以这种方式使用花,但在我看来这是错误的。我可以找到另一个错误,即您将location /flower/static/ 放在location /flower/ 下面,因此所有静态请求都将由location /flower/ 代码块处理

    你的 nginx 配置应该是这样的:

    server {
        location /flower/static {
            alias  /the/path/to/flower/static;
        }
        location /flower {
            rewrite ^/flower/(.*)$ /$1 break;
            proxy_pass http://localhost:5555;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
        }
    }
    

    您可以在documentationexample 上阅读有关设置的更多信息

    【讨论】:

      【解决方案2】:

      通过将--url_prefix=flower 更改为--url_prefix=/flower,它已为我修复。

      【讨论】:

        猜你喜欢
        • 2023-03-25
        • 1970-01-01
        • 2022-06-13
        • 1970-01-01
        • 2018-03-12
        • 1970-01-01
        • 2011-11-10
        • 2016-05-05
        • 1970-01-01
        相关资源
        最近更新 更多