Skip to content

Instantly share code, notes, and snippets.

@thenewguy
Forked from hlawrenz/flower command line
Created June 28, 2018 19:32
Show Gist options
  • Save thenewguy/d65418957dda538cb99a246b172ce02a to your computer and use it in GitHub Desktop.
Save thenewguy/d65418957dda538cb99a246b172ce02a 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment