Last active
February 5, 2023 19:00
-
-
Save hlawrenz/11219276 to your computer and use it in GitHub Desktop.
Serve celery flower behind Django authentication.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
celery flower --address=127.0.0.1 --url_prefix=flower --broker=<broker url> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /rewolf/ { | |
internal; | |
rewrite ^/rewolf/(.*)$ /$1 break; | |
proxy_pass http://127.0.0.1:5555; | |
proxy_set_header Host $host; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls import patterns, include, url | |
urlpatterns = patterns( | |
'', | |
url(r'^flower/', 'internal.views.flower_view'), | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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?
Or task revoke endpoint
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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