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 seahub_settings.py I have:
SERVE_STATIC = True
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”).
Workaround:
--- seahub/seahub/urls.py.ori 2016-11-16 04:10:25.000000000 +0100
+++ seahub/seahub/urls.py 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.