Skip to content

Instantly share code, notes, and snippets.

@mx-moth
Created December 28, 2013 11:58
Show Gist options
  • Save mx-moth/8158686 to your computer and use it in GitHub Desktop.
Save mx-moth/8158686 to your computer and use it in GitHub Desktop.
We use a combination of nginx and to run our Django things at work. It works well. The relevant configs are attached. http://cr.yp.to/daemontools.html
#!/usr/bin/env bash
type='django'
site='timheap.me'
project='tfs-roster'
sitepath="/var/www/$site/$project"
pid="$sitepath/var/pid"
socket="$sitepath/var/socket"
source "$sitepath/venv/bin/activate"
cd "$sitepath/src"
exec setuidgid www-data \
python manage.py runfcgi \
socket="$socket" \
pidfile="$pid" \
maxrequests=100 \
minspare=1 maxspare=2 \
daemonize=False
server {
listen 80;
server_name tfs.timheap.me;
error_log /var/log/nginx/tfs.timheap.me.log;
access_log off;
log_not_found on;
expires 30d;
# Alias in the assets
location /assets/ {
alias /var/www/timheap.me/tfs-roster/var/www/;
}
# May as well put these in, as they must be in standard locations
location /crossdomain.xml { alias /var/www/timheap.me/tfs-roster/var/www/static/crossdomain.xml; }
location /favicon.ico { alias /var/www/timheap.me/tfs-roster/var/www/static/favicon.ico; }
location /humans.txt { alias /var/www/timheap.me/tfs-roster/var/www/static/humans.txt; }
location /robots.txt { alias /var/www/timheap.me/tfs-roster/var/www/static/robots.txt; }
location / {
expires 0d;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
fastcgi_pass unix:/var/www/timheap.me/tfs-roster/var/socket;
# These are not in the above
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment