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

add reverse proxy for flower #2998

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions bookwyrm/templates/settings/layout.html
Expand Up @@ -89,6 +89,9 @@ <h2 class="menu-label">{% trans "System" %}</h2>
{% url 'settings-schedules' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Scheduled tasks" %}</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>
Expand Down
1 change: 1 addition & 0 deletions bookwyrm/urls.py
Expand Up @@ -29,6 +29,7 @@
STREAMS = "|".join(s["key"] for s in settings.STREAMS)

urlpatterns = [
views.FlowerProxyView.as_url(),
path("admin/", admin.site.urls),
path(
"robots.txt",
Expand Down
17 changes: 17 additions & 0 deletions bookwyrm/views/admin/flower.py
@@ -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')