Skip to content

Instantly share code, notes, and snippets.

@hlawrenz
Last active February 5, 2023 19:00
Show Gist options
  • Save hlawrenz/11219276 to your computer and use it in GitHub Desktop.
Save hlawrenz/11219276 to your computer and use it in GitHub Desktop.
Serve celery flower behind Django authentication.
celery flower --address=127.0.0.1 --url_prefix=flower --broker=<broker url>
location /rewolf/ {
internal;
rewrite ^/rewolf/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:5555;
proxy_set_header Host $host;
}
from django.conf.urls import patterns, include, url
urlpatterns = patterns(
'',
url(r'^flower/', 'internal.views.flower_view'),
)
from django.http import HttpResponse
from django.contrib.auth.decorators import user_passes_test
@user_passes_test(lambda u: u.is_staff)
def flower_view(request):
response = HttpResponse()
path = request.get_full_path()
path = path.replace('flower', 'rewolf', 1)
response['X-Accel-Redirect'] = path
return response
@hynek2001
Copy link

hynek2001 commented Jan 20, 2017

hi,
but your solution means, if users learn, url is /rewolf , then they can access it without any issues... am i right ?

edit1:
oh i see, there is "internal" , this is genial...thx
Hynek

@thenewguy
Copy link

How do you get post requests to work? I tried csrf exempt on the django view but still got errors. Should this work for say, the restart worker pool form submit?

@thenewguy
Copy link

Or task revoke endpoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment