Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running flower with a url prefix #13

Closed
wants to merge 2 commits into from

Conversation

theospears
Copy link

We run a number of monitoring services and dashboards on our machines behind nginx, each accessible under a different prefix (http://www.example.com/munin/, http://www.example.com/rabbitmq, etc.) This doesn't work with flower as it expects to always be at the root of the host it is running under.

This patch adds a --prefix command line option allowing you to specify a prefix. This means it can be run under an arbitrary location.

@mher
Copy link
Owner

mher commented Sep 24, 2012

Thanks for the patch! Why don't you use tornado static_url_prefix option?

@mher
Copy link
Owner

mher commented Sep 24, 2012

static_url_prefix combined with nginx rewrite seems a better solution

@theospears
Copy link
Author

My initial attempt just used nginx rewriting, but I found this was ineffective as flower generates and uses lots of absolute URLs for its webservice and url endpoints. Just nginx rewriting results in these being broken links.

My understanding from reading the tornado source is that static_url_prefix only affects static resources, so I don't follow how this is sufficient to make non-static resources link properly.

@mher
Copy link
Owner

mher commented Sep 24, 2012

$(location) can be used in js to get a prefix for non-static urls

@mher
Copy link
Owner

mher commented Nov 17, 2012

A new --url_prefix option enables to deploy flower with url prefix

@mher
Copy link
Owner

mher commented Nov 17, 2012

To access flower from http://example.com/flower simply run "flower --url_prefix=flower" and use nginx rewrite ^/flower/(.*)$ /$1

@mher
Copy link
Owner

mher commented Nov 17, 2012

Sample nginx config:

server {
    listen 80;
    server_name localhost;

    location /flower/ {
        rewrite ^/flower/(.*)$ /$1 break;
        proxy_pass http://localhost:5555;
        proxy_set_header Host $host;
    }

}

@geoffjukes
Copy link
Contributor

In case anyone else uses this sample, I found I needed to make the match a regex, and the slash optional, because the link behind the 'Celery Flower' label/logo is generated without a trailing slash. Not a big deal, just annoyed me :)

server {
    listen 80;
    server_name localhost;

    location ~ ^/flower/? {
        rewrite ^/flower/?(.*)$ /$1 break;
        proxy_pass http://localhost:5555;
        proxy_set_header Host $host;
    }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants