Django app to easy configuration of multiple X-File-Accel locations
Project description
This app allowes you to protect static files served by nginx with authorization of your django project
Protecting files
This example will show how to protect 2 file positions from downloading:
{static_url}/files/fbi
{static_url}/files/cia
In this example we will assume that static url is /static/
Steps to protect files:
in nginx config disable access to desired locations:
location
/static/files/fbi{ denyall; } location/static/files/cia{ denyall; }Add internal path to serve this files. We will add “root” directory to serve both locations with one configuration option:
# needed for x-file-accell location
/internal/files/{ internal; alias $project_base/static/files/; }Configure x_file_accel_redirects app:
Set settings.X_FILE_ACCEL = True.
add "x_file_accel_redirects" to settings.INSTALLED_APPS.
Add app to your root url config, e.g.:
urlpatterns += patterns('', (r'^protected/', include('x_file_accel_redirects.urls')), )
In django admin create new instance of x_file_accel_redirects.AccelRedirect with next values:
Description: anything meaningful.
URL prefix: any latin letters without slashes, e.g. “downloads”.
Login required: True.
Internal path: “/internal/files/”” (as specified in nginx config).
serve document root: optionaly you can specify path to directory with needed files to serve them with django staticfiles app when settings.X_FILE_ACCEL == False.
When everything is configured and restarted you will be able to get file $project_base/static/files/fbi/secrets/ufo.txt by next url:
/protected/downloads/fbi/secrets/ufo.txt (/downloads/ if from “prefix” field of AccelRedirect)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-x_file_accel_redirects-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b9e4d13411b18b9f5e065453065a3ad58fae1fd1d02a0b8a7c203588fe5292d |
|
MD5 | 849e500ae35489ef8c6557a527fb4610 |
|
BLAKE2b-256 | 1855780c6132ef256564c26ae239d12db85947b4ea017adca2eb15ea7b96a224 |
Hashes for django-x_file_accel_redirects-0.0.1.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03aa703f0d2450671edfb7a07febbdd631d78958366740432c26516b4c25dbd6 |
|
MD5 | 744024701e156fc2f1564aa71df67d28 |
|
BLAKE2b-256 | bc56ea317b3bd5b95bbd2643fb4e3427911ad35cba64744b8d00d34a50ea1bd6 |