Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
puppet: Simplify uploads handling.
Alex Vandiveraae8f454ce2e
diff --git a/puppet/zulip/files/nginx/zulip-include-frontend/app b/puppet/zulip/files/nginx/zulip-include-frontend/appindex 29dc7104ad2..8838a9d81d5 100644--- a/puppet/zulip/files/nginx/zulip-include-frontend/app+++ b/puppet/zulip/files/nginx/zulip-include-frontend/app@@ -54,8 +54,7 @@ location / {# web, and thus need API headers added. We can't easily collapse# these blocks with the /api block, because regular expressions take# priority over paths in nginx's order-of-operations, and we don't-# want to override the tornado configuration for /api/v1/events. The-# last is handled via uploads-route.+# want to override the tornado configuration for /api/v1/events.location /thumbnail {include /etc/nginx/zulip-include/api_headers;@@ -66,6 +65,11 @@ location /avatar {include uwsgi_params;}+location /user_uploads {+ include /etc/nginx/zulip-include/api_headers;++ include uwsgi_params;+}# Send all API routes not covered above to Django via uWSGIlocation /api/ {@@ -74,5 +78,4 @@ location /api/ {include uwsgi_params;}-include /etc/nginx/zulip-include/uploads.route;include /etc/nginx/zulip-include/app.d/*.conf;diff --git a/puppet/zulip/files/nginx/zulip-include-maybe/uploads-route.internal b/puppet/zulip/files/nginx/zulip-include-maybe/uploads-internal.confsimilarity index 53%rename from puppet/zulip/files/nginx/zulip-include-maybe/uploads-route.internalrename to puppet/zulip/files/nginx/zulip-include-maybe/uploads-internal.confindex b7dba765085..add9e1fbc62 100644--- a/puppet/zulip/files/nginx/zulip-include-maybe/uploads-route.internal+++ b/puppet/zulip/files/nginx/zulip-include-maybe/uploads-internal.conf@@ -5,13 +5,3 @@ location /serve_uploads {include /etc/nginx/zulip-include/uploads.types;alias /home/zulip/uploads/files;}--# This Django route not under /api is shared between mobile and web-# and thus needs API headers added, in addition to the configuration-# required to have this URL be served by Django.--location /user_uploads {- include /etc/nginx/zulip-include/api_headers;-- include uwsgi_params;-}diff --git a/puppet/zulip/files/nginx/zulip-include-maybe/uploads-route.noserve b/puppet/zulip/files/nginx/zulip-include-maybe/uploads-route.noservedeleted file mode 100644index cf3bd562292..00000000000--- a/puppet/zulip/files/nginx/zulip-include-maybe/uploads-route.noserve+++ /dev/null@@ -1,9 +0,0 @@-# This Django route not under /api is shared between mobile and web-# and thus needs API headers added, in addition to the configuration-# required to have this URL be served by Django.--location /user_uploads {- include /etc/nginx/zulip-include/api_headers;-- include uwsgi_params;-}diff --git a/puppet/zulip/manifests/nginx.pp b/puppet/zulip/manifests/nginx.ppindex 8c123db2977..418fdd87000 100644--- a/puppet/zulip/manifests/nginx.pp+++ b/puppet/zulip/manifests/nginx.pp@@ -29,24 +29,39 @@ class zulip::nginx {notify => Service['nginx'],}+ # Configuration for how uploaded files are served. The default is+ # to serve uploaded files using using the `nginx` `internal`+ # feature via django-sendfile2, which basically does an internal+ # redirect and returns the file content from nginx in an+ # HttpResponse that would otherwise have been a redirect.+ #+ # For installations using S3 to serve uploaded files, we want Django+ # to handle the /serve_uploads route, so that it can do authentication+ # and serve a redirect.$no_serve_uploads = zulipconf('application_server', 'no_serve_uploads', '')- if $no_serve_uploads != '' {- # If we're not serving uploads locally, set the appropriate API headers for it.- $uploads_route = 'puppet:///modules/zulip/nginx/zulip-include-maybe/uploads-route.noserve'+ if $no_serve_uploads == '' {+ file { '/etc/nginx/zulip-include/app.d/uploads-internal.conf':+ ensure => file,+ require => Package[$zulip::common::nginx],+ owner => 'root',+ group => 'root',+ mode => '0644',+ notify => Service['nginx'],+ source => 'puppet:///modules/zulip/nginx/zulip-include-maybe/uploads-internal.conf',+ }} else {- $uploads_route = 'puppet:///modules/zulip/nginx/zulip-include-maybe/uploads-route.internal'+ file { '/etc/nginx/zulip-include/app.d/uploads-internal.conf':+ ensure => absent,+ }}+ # Removed 2021-04 in Zulip 4.0; these lines can be removed in Zulip+ # version 5.0 and later.file { '/etc/nginx/zulip-include/uploads.route':- ensure => file,- require => Package[$zulip::common::nginx],- owner => 'root',- group => 'root',- mode => '0644',- notify => Service['nginx'],- source => $uploads_route,+ ensure => absent,}+file { '/etc/nginx/dhparam.pem':ensure => file,require => Package[$zulip::common::nginx],