Skip to content
This repository was archived by the owner on Feb 29, 2020. It is now read-only.
This repository was archived by the owner on Feb 29, 2020. It is now read-only.

Nginx deployment notes might lead to security issues? #13

@tijs

Description

@tijs

As noted on Twitter earlier i was wondering if the recommendation for setting up nginx should come with a warning to make sure the root var in the nginx config is pointing to a directory with your static files not the root of your django app.

Your config uses the handy try_files shortcut:

root        /var/www/domain.com/;

# Check if a file exists at /var/www/domain/ for the incoming request.
# If it doesn't proxy to Gunicorn/Django.
try_files $uri @django;

This is fine if domain.com has your static files but if you deploy a standard (instead of your suggestion from another part of the best practices) django app layout on your server it will make any python file, including your settings, available for download.

For instance if this is (part of) your app layout:

/var/www/domain.com/
    |- manage.py
    |- settings.py
    |- static/
        |- style.css

A call to http://domain.com/static/style.css will load fine and make it look like you did a fine job deploying following best practices. While at the same time http://domain.com/settings.py will start a download of your settings.py file.

Obviously this is bad and you should not point the root to your app but i'm betting people will read that tip which they will find when googling and then do exactly this...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions