Compare commits

...

2 commits

Author SHA1 Message Date
Robert R George 3edd255cbd
Merge 218e248ed3 into 193aeff4d2 2024-01-29 23:56:11 -07:00
Robert George 218e248ed3
add reverse proxy for flower 2023-09-16 18:52:29 -07:00
3 changed files with 21 additions and 0 deletions

View file

@ -85,6 +85,9 @@
{% url 'settings-celery' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Celery status" %}</a>
</li>
<li>
<a href="/flower/"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Flower" %}</a>
</li>
<li>
{% url 'settings-email-config' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Email Configuration" %}</a>

View file

@ -29,6 +29,7 @@ BOOK_PATH = r"^book/(?P<book_id>\d+)"
STREAMS = "|".join(s["key"] for s in settings.STREAMS)
urlpatterns = [
views.FlowerProxyView.as_url(),
path("admin/", admin.site.urls),
path(
"robots.txt",

View file

@ -0,0 +1,17 @@
from django.contrib.auth.mixins import UserPassesTestMixin
from django.urls import path, re_path
from revproxy.views import ProxyView
class FlowerProxyView(UserPassesTestMixin, ProxyView):
upstream = 'http://{}:{}'.format('localhost', 8888)
url_prefix = 'flower'
rewrite = (
(r'^/{}$'.format(url_prefix), r'/{}/'.format(url_prefix)),
)
def test_func(self):
return self.request.user.is_superuser
@classmethod
def as_url(cls):
return re_path(r'^(?P<path>{}.*)$'.format(cls.url_prefix), cls.as_view(), name='flower')