Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running flower behind a reverse proxy

The following is my nginx config:

    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;
}

Link for the above: https://github.com/mher/flower/issues/414

My flower version is 0.9.2 and nginx version is 1.12.1

I ran flower as follows:

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

This renders the following: enter image description here

I ran flower as follows: (used --url_prefix=flower)

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

This then rendered all the static files as shown: enter image description here

The problem occurs when I click on any of the tabs (say tasks) above as shown: enter image description here

I noticed that the url instead of being say: /flower/dashboard/ is /flower/flower/dashboard and so on.

What am I missing here? Anything to be changed in nginx config?

like image 270
Adarsh Avatar asked Oct 14 '25 14:10

Adarsh


1 Answers

If flower is running like that:

celery --broker=amqp://broker_url:port flower --port=5555 --url_prefix=/flower

then nginx config requires only:

location /flower/ {
        proxy_pass http://localhost:5555/flower/;
    }

add it should work. In my case, I used flower 1.2.0

like image 190
Michał Kwaśniewicz Avatar answered Oct 17 '25 17:10

Michał Kwaśniewicz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!