Skip to main content

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:

  1. in nginx config disable access to desired locations:

    location /static/files/fbi {
        deny all;
    }
    location /static/files/cia {
        deny all;
    }
  2. 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/;
    }
  3. Configure x_file_accel_redirects app:

    1. Set settings.X_FILE_ACCEL = True.

    2. add "x_file_accel_redirects" to settings.INSTALLED_APPS.

    3. Add app to your root url config, e.g.:

      urlpatterns += patterns('',
          (r'^protected/', include('x_file_accel_redirects.urls')),
      )
    4. 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)

Metadata

Release files for django-x_file_accel_redirects 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-x_file_accel_redirects 0.0.2
File Size Uploaded Provenance
django-x_file_accel_redirects-0.0.2.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-x_file_accel_redirects 0.0.2
File Interpreter ABI Platform
django-x_file_accel_redirects-0.0.2.linux-x86_64.tar.gz Details

Total release size: 14.1 kB

Release files / django-x_file_accel_redirects-0.0.2.tar.gz

Download URL django-x_file_accel_redirects-0.0.2.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
91ee56dcf227fc64229dfa48faaeeef07c1cccc207ba83caa8e7d28dc31a12a8
BLAKE2b-256 checksum
How to use checksums
5d1a1f7eed74cbcc262b373f91e7cc01c5f83431776348da44de12d5bfa9ae65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django-x_file_accel_redirects-0.0.2.linux-x86_64.tar.gz

Download URL django-x_file_accel_redirects-0.0.2.linux-x86_64.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7eb3512367442d489622acdb227c19bcab7193f2eeec9c944f59004b627377fe
BLAKE2b-256 checksum
How to use checksums
655d8e814fa9e546429df648678e3b9e84e33e8aadefe0f66c99b89b45d1f9c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-x_file_accel_redirects 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page