diff --git a/apps/jumpserver/rewriting/storage/servers.py b/apps/jumpserver/rewriting/storage/servers.py new file mode 100644 index 000000000..5fc4b0514 --- /dev/null +++ b/apps/jumpserver/rewriting/storage/servers.py @@ -0,0 +1,14 @@ +from private_storage.servers import NginxXAccelRedirectServer, DjangoServer + + +class StaticFileServer(object): + + @staticmethod + def serve(private_file): + full_path = private_file.full_path + # todo: gzip 文件录像 nginx 处理后,浏览器无法正常解析内容 + # 造成在线播放失败,暂时仅使用 nginx 处理 mp4 录像文件 + if full_path.endswith('.mp4'): + return NginxXAccelRedirectServer.serve(private_file) + else: + return DjangoServer.serve(private_file) diff --git a/apps/jumpserver/settings/base.py b/apps/jumpserver/settings/base.py index 4fdba8b97..10188a1a7 100644 --- a/apps/jumpserver/settings/base.py +++ b/apps/jumpserver/settings/base.py @@ -319,9 +319,7 @@ MEDIA_ROOT = os.path.join(PROJECT_DIR, 'data', 'media').replace('\\', '/') + '/' PRIVATE_STORAGE_ROOT = MEDIA_ROOT PRIVATE_STORAGE_AUTH_FUNCTION = 'jumpserver.rewriting.storage.permissions.allow_access' PRIVATE_STORAGE_INTERNAL_URL = '/private-media/' -PRIVATE_STORAGE_SERVER = 'nginx' -if DEBUG_DEV: - PRIVATE_STORAGE_SERVER = 'django' +PRIVATE_STORAGE_SERVER = 'jumpserver.rewriting.storage.servers.StaticFileServer' # Use django-bootstrap-form to format template, input max width arg