Skip to content

Instantly share code, notes, and snippets.

@ba11b0y
Last active May 3, 2018 05:42
Show Gist options
  • Save ba11b0y/61a3c58749f0878b80694bb3b60b3789 to your computer and use it in GitHub Desktop.
Save ba11b0y/61a3c58749f0878b80694bb3b60b3789 to your computer and use it in GitHub Desktop.
Directory structure and nginx config for serving static files
.
├── csite
│   ├── admin.py
│   ├── admin.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── migrations
│   │   ├── __init__.py
│   │   └── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── templates
│   │   ├── contact.html
│   │   └── index.html
│   ├── tests.py
│   └── views.py
├── db.sqlite3
├── django_project
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings.py
│   ├── settings.pyc
│   ├── settings.py.orig
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
├── manage.py
└── static
    └── csite
        ├── admin
        │   ├── css
        │   │   ├── base.css
        │   │   ├── changelists.css
        │   │   ├── dashboard.css
        │   │   ├── forms.css
        │   │   ├── ie.css
        │   │   ├── login.css
        │   │   ├── rtl.css
        │   │   └── widgets.css
        │   ├── img
        │   │   ├── changelist-bg.gif
        │   │   ├── changelist-bg_rtl.gif
        │   │   ├── default-bg.gif
        │   │   ├── default-bg-reverse.gif
        │   │   ├── deleted-overlay.gif
        │   │   ├── gis
        │   │   │   ├── move_vertex_off.png
        │   │   │   └── move_vertex_on.png
        │   │   ├── icon_addlink.gif
        │   │   ├── icon_alert.gif
        │   │   ├── icon_calendar.gif
        │   │   ├── icon_changelink.gif
        │   │   ├── icon_clock.gif
        │   │   ├── icon_deletelink.gif
        │   │   ├── icon_error.gif
        │   │   ├── icon-no.gif
        │   │   ├── icon_searchbox.png
        │   │   ├── icon_success.gif
        │   │   ├── icon-unknown.gif
        │   │   ├── icon-yes.gif
        │   │   ├── inline-delete-8bit.png
        │   │   ├── inline-delete.png
        │   │   ├── inline-restore-8bit.png
        │   │   ├── inline-restore.png
        │   │   ├── inline-splitter-bg.gif
        │   │   ├── nav-bg.gif
        │   │   ├── nav-bg-grabber.gif
        │   │   ├── nav-bg-reverse.gif
        │   │   ├── nav-bg-selected.gif
        │   │   ├── selector-icons.gif
        │   │   ├── selector-search.gif
        │   │   ├── sorting-icons.gif
        │   │   ├── tooltag-add.png
        │   │   └── tooltag-arrowright.png
        │   └── js
        │       ├── actions.js
        │       ├── actions.min.js
        │       ├── admin
        │       │   ├── DateTimeShortcuts.js
        │       │   └── RelatedObjectLookups.js
        │       ├── calendar.js
        │       ├── collapse.js
        │       ├── collapse.min.js
        │       ├── core.js
        │       ├── inlines.js
        │       ├── inlines.min.js
        │       ├── jquery.init.js
        │       ├── jquery.js
        │       ├── jquery.min.js
        │       ├── LICENSE-JQUERY.txt
        │       ├── prepopulate.js
        │       ├── prepopulate.min.js
        │       ├── related-widget-wrapper.js
        │       ├── SelectBox.js
        │       ├── SelectFilter2.js
        │       ├── timeparse.js
        │       └── urlify.js
        └── csite
            ├── css
            │   ├── style1.css
            │   └── style.css
            └── images
                ├── background.jpg
                ├── background.png
                ├── bootstrap2.png
                ├── bootstrap.png
                ├── b.png
                ├── conus.png
                ├── cunt.png
                ├── finlogo.png
                ├── finlogosmall.png
                ├── less.png
                ├── mountains.jpeg
                ├── quote.jpg
                ├── sass.png
                ├── team1.png
                ├── team2.png
                ├── team3.png
                ├── team4.png
                ├── team5.png
                └── w3newbie.png

nginx-conf

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.html index.htm;

client_max_body_size 4G;
server_name _;

keepalive_timeout 5;

# Your Django project's media files - amend as required
location /media  {
    alias /home/django/django_project/django_project/media;
}

# your Django project's static files - amend as required
location /static/ {
    alias /home/django/django_project/static/csite/;
    autoindex on;
}

# Proxy the static assests for the Django Admin panel
location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_buffering off;

        proxy_pass http://app_server;
}

}

settings.py

STATIC_ROOT = os.path.join(BASE_DIR, "static/csite") # Although this can be modified to "static" only to avoid a complex     dir structure
# URL prefix for static files.
STATIC_URL = '/static/'


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment