Browse Source

Updated settings for fileserver

Rafał Pitoń 11 years ago
parent
commit
b34da1524c

+ 34 - 0
docs/developers/settings.rst

@@ -178,6 +178,18 @@ MISAGO_ADMIN_SESSION_EXPIRATION
 Maximum allowed lenght of inactivity period between two requests to admin namespaces. If its exceeded, user will be asked to sign in again to admin backed before being allowed to continue activities.
 
 
+MISAGO_ATTACHMENTS_ROOT
+-----------------------
+
+Path to directory that Misago should use to store post attachments. This directory shouldn't be accessible from outside world.
+
+
+MISAGO_AVATAR_CACHE
+-------------------
+
+Path to directory that Misago should use to store cached avatars. This directory shouldn't be accessible from outside world.
+
+
 MISAGO_AVATARS_SIZES
 --------------------
 
@@ -202,6 +214,28 @@ MISAGO_MARKUP_EXTENSIONS
 List of python modules extending Misago markup.
 
 
+MISAGO_SENDFILE_HEADER
+----------------------
+
+If your server provides proxy for serving files from application, like "X-Sendfile", set its header name in this setting.
+
+Leave this setting empty to use Django fallback.
+
+
+MISAGO_SENDFILE_LOCATIONS_PATH
+------------------------------
+
+Some Http servers (like Nginx) allow you to restrict X-Sendfile to certain locations.
+
+Misago supports this feature with this setting, however with limitation to one "root" path. This setting is used for paths defined in ATTACHMENTS_ROOT and AVATAR_CACHE settings.
+
+Rewrite algorithm used by Misago replaces path until last part with value of this setting.
+
+For example, defining ``MISAGO_SENDFILE_LOCATIONS_PATH = 'misago_served_internals'`` will result in following rewrite:
+
+``/home/mysite/www/attachments/13_05/142123.rar`` => ``/misago_served_internals/attachments/13_05/142123.rar``
+
+
 password_complexity
 -------------------
 

+ 17 - 0
misago/conf/defaults.py

@@ -229,6 +229,23 @@ MISAGO_INITIALS_AVATAR_FUNCTION = 'misago.users.avatars.initials.set_user_avatar
 MISAGO_AVATARS_SIZES = (150, 100, 64, 50, 30, 20)
 
 
+# X-Sendfile
+# X-Sendfile is feature provided by Http servers that allows web apps to
+# delegate serving files over to the better performing server instead of
+# doing it within app.
+# If your server supports X-Sendfile or its variation, enter header name here.
+# For example if you are using Nginx with X-accel enabled, set this setting
+# to "X-Accel-Redirect".
+# Leave this setting empty to Django fallback instead
+MISAGO_SENDFILE_HEADER = ''
+
+# Allows you to use location feature of your Http server
+# For example, if you have internal location /mymisago/avatar_cache/
+# that points at /home/myweb/misagoforum/avatar_cache/, set this setting
+# to "mymisago".
+MISAGO_SENDFILE_LOCATIONS_PATH = ''
+
+
 # Default forms templates
 CRISPY_TEMPLATE_PACK = 'bootstrap3'
 

+ 20 - 2
misago/project_template/project_name/settings.py

@@ -67,8 +67,9 @@ MEDIA_URL = '/media/'
 
 
 # Automatically setup default paths to media and attachments directories
-ATTACHMENTS_ROOT = os.path.join(BASE_DIR, 'attachments')
-AVATAR_CACHE = os.path.join(BASE_DIR, 'avatar_cache')
+MISAGO_ATTACHMENTS_ROOT = os.path.join(BASE_DIR, 'attachments')
+MISAGO_AVATAR_CACHE = os.path.join(BASE_DIR, 'avatar_cache')
+
 MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
 STATIC_ROOT = os.path.join(BASE_DIR, 'static')
 
@@ -89,6 +90,23 @@ TEMPLATE_DIRS = (
 SECRET_KEY = '{{ secret_key }}'
 
 
+# X-Sendfile support
+# X-Sendfile is feature provided by Http servers that allows web apps to
+# delegate serving files over to the better performing server instead of
+# doing it within app.
+# If your server supports X-Sendfile or its variation, enter header name here.
+# For example if you are using Nginx with X-accel enabled, set this setting
+# to "X-Accel-Redirect".
+# Leave this setting empty to Django fallback instead
+MISAGO_SENDFILE_HEADER = ''
+
+# Allows you to use location feature of your Http server
+# For example, if you have internal location /mymisago/avatar_cache/
+# that points at /home/myweb/misagoforum/avatar_cache/, set this setting
+# to "mymisago".
+MISAGO_SENDFILE_LOCATIONS_PATH = ''
+
+
 # Application definition
 # Don't edit those settings unless you know what you are doing
 ROOT_URLCONF = '{{ project_name }}.urls'