Seahub with SERVE_STATIC=True behind apache on different machine

The Server serving Seafile is on private subnet.
There’s a public accessible apache with mod_proxy and ProxyPass /seafile fcgi:/… to the Seahub Service.
seahub runs in fastcgi mode.
seahub shall serve it’s static files because there’s no apache/nginx running on the same machine.

In I have:
SITE_ROOT = ‘/seafile/’

That won’t work, because seafile is linking media files to “/media”, which is not below “/seafile” and therefore doesn’t reach seahub.

Thus adding:
MEDIA_URL = ‘/seafile/media/’

That also won’t work, because seafile now is linking media files to “/seafile/media/” while serving media files on “/seafile/seafile/media/” (which is “SITE_ROOT/MEDIA_URL”).


--- seahub/seahub/	2016-11-16 04:10:25.000000000 +0100
+++ seahub/seahub/	2016-11-24 13:52:15.604912541 +0100
@@ -303,7 +303,11 @@ if EVENTS_ENABLED:
 if settings.SERVE_STATIC:
-    media_url = settings.MEDIA_URL.strip('/')
+    media_url = settings.MEDIA_URL
+    site_root = settings.SITE_ROOT
+    if media_url.startswith(site_root):
+        media_url = media_url[len(site_root):]
+    media_url = media_url.strip('/')
     urlpatterns += patterns('',
         (r'^%s/(?P<path>.*)$' % (media_url), 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),

For me this works as expected.

1 Like

It’s Seafile 6.1.1 now and this is still needed - and working, fortunately.

1 Like

I can hardly believe that I’m responding to your message in 2023… But here I am with exactly the same issue. It took me a while to understand the “/seafile/seafile/media/” problem… it’s literally the snake that eats its own tail, and I can’t, for the life of me, make your trick work.

What did you set MEDIA_URL to?

Edit: Actually nevermind… I had SERVE_STATIC at False… Your workaround works perfectly and is a lifesaver. Thank you so much.
My now looks like this:

MEDIA_URL = '/seafile/media/'
STATIC_URL = MEDIA_URL + 'assets/'
SITE_ROOT = '/seafile/'
LOGIN_URL = '/seafile/accounts/login/'

Oh, good that you have find the solution by yourself. I cannot help you here anymore.
But I wonder it’s still working. What Seafile version do we have nowadays!? :wink:

I’m running version 9.0.10 haha, and your trick still works :joy:
Did you move to a different product?