http {
# [here must be all standard parameters]
server {
server_name example.com;
listen 80;
root /home/mydjangoproject/www;
# django
set $django 1;
# ,
#
if ($is_args = "?") {
set $args_old ?$args;
}
if ($is_args = "") {
set $args_old "";
}
# ,
#
default_type text/html;
location / {
if (-f $request_filename/index.html$args_old) {
set $django 0;
}
#
if ($http_cookie ~* "sessionid=([^;]+)(?:;|$)" ) {
set $django 1;
}
#
if ($django = 0) {
rewrite (.*) $1/index.html$args_old break;
}
# django
if ($django) {
fastcgi_pass unix:/home/mydjangoproject/dj.sock;
break;
}
index index.html;
include conf/fastcgi.conf;
access_log logs/project.log main;
}
}
}
http {
# [here must be all standard parameters]
server {
server_name example.com;
listen 80;
root /home/mydjangoproject/www;
# django
set $django 1;
# ,
#
if ($is_args = "?") {
set $args_old ?$args;
}
if ($is_args = "") {
set $args_old "";
}
# ,
#
default_type text/html;
location / {
if (-f $request_filename/index.html$args_old) {
set $django 0;
}
#
if ($http_cookie ~* "sessionid=([^;]+)(?:;|$)" ) {
set $django 1;
}
#
if ($django = 0) {
rewrite (.*) $1/index.html$args_old break;
}
# django
if ($django) {
fastcgi_pass unix:/home/mydjangoproject/dj.sock;
break;
}
index index.html;
include conf/fastcgi.conf;
access_log logs/project.log main;
}
}
}
log_format main '$remote_addr [$time_local] "$request" '
'$status $bytes_sent $body_bytes_sent $gzip_ratio '
'$django "$http_referer" "$http_user_agent"';
from os import path
WEB_ROOT = path.realpath("www")
STATIC_GENERATOR_EXCLUDED = (
'/comments/postfree',
'/rating',
'/rss',
'/admin',
)
Source: https://habr.com/ru/post/20922/