uploads: Move internal upload serving path to under /internal/.

This commit is contained in:
Alex Vandiver 2022-12-09 00:12:06 +00:00 committed by Alex Vandiver
parent b20ecabf8f
commit 24f95a3788
4 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
location /serve_uploads { location /internal/uploads {
internal; internal;
include /etc/nginx/zulip-include/api_headers; include /etc/nginx/zulip-include/api_headers;
add_header Content-Security-Policy "default-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self'; object-src 'self'; plugin-types application/pdf;"; add_header Content-Security-Policy "default-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self'; object-src 'self'; plugin-types application/pdf;";

View File

@ -77,7 +77,7 @@ class zulip::app_frontend_base {
# pictures are served directly off disk. # pictures are served directly off disk.
# #
# For installations using S3 to serve uploaded files, we want Django # For installations using S3 to serve uploaded files, we want Django
# to handle the /serve_uploads and /user_avatars routes, so that it # to handle the /internal/uploads and /user_avatars routes, so that it
# can serve a redirect (after doing authentication, for uploads). # can serve a redirect (after doing authentication, for uploads).
$no_serve_uploads = zulipconf('application_server', 'no_serve_uploads', false) $no_serve_uploads = zulipconf('application_server', 'no_serve_uploads', false)
if $no_serve_uploads { if $no_serve_uploads {

View File

@ -948,7 +948,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
test_run, worker = os.path.split(os.path.dirname(settings.LOCAL_UPLOADS_DIR)) test_run, worker = os.path.split(os.path.dirname(settings.LOCAL_UPLOADS_DIR))
self.assertEqual( self.assertEqual(
response["X-Accel-Redirect"], response["X-Accel-Redirect"],
"/serve_uploads/" + fp_path + "/" + name_str_for_test, "/internal/uploads/" + fp_path + "/" + name_str_for_test,
) )
if content_disposition != "": if content_disposition != "":
self.assertIn("attachment;", response["Content-disposition"]) self.assertIn("attachment;", response["Content-disposition"])

View File

@ -115,7 +115,7 @@ def serve_local(
patch_cache_control(response, private=True, immutable=True) patch_cache_control(response, private=True, immutable=True)
return response return response
response = internal_nginx_redirect(quote(f"/serve_uploads/{path_id}")) response = internal_nginx_redirect(quote(f"/internal/uploads/{path_id}"))
patch_disposition_header(response, local_path, attachment) patch_disposition_header(response, local_path, attachment)
patch_cache_control(response, private=True, immutable=True) patch_cache_control(response, private=True, immutable=True)
return response return response