umap/fabfile/nginx.conf
Yohan Boniface ec5200bcbc WIP
2017-05-12 10:51:19 +02:00

63 lines
1.5 KiB
Nginx Configuration File

# the upstream component nginx needs to connect to
upstream umap {
server unix:///srv/umap/uwsgi.sock;
}
proxy_cache_path /tmp/nginx_ajax_proxy_cache levels=1:2 keys_zone=ajax_proxy:10m inactive=60m;
proxy_cache_key "$args";
# configuration of the server
server {
# the port your site will be served on
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
# the domain name it will serve for
server_name $$domain;
charset utf-8;
# max upload size
client_max_body_size 25M; # adjust to taste
# Django media
location /uploads/ {
alias /srv/umap/media_root/;
expires 30d;
}
location /static/ {
alias /srv/umap/static_root/;
}
# X-Accel-Redirect
location /internal/ {
gzip off;
add_header Content-Encoding gzip;
internal;
alias /srv/umap/media_root/;
}
location /ajax-proxy/ {
valid_referers server_names;
if ($invalid_referer) {
return 404;
}
if ($args !~ ^url=(.*)$) {
return 404;
}
if ($args ~ ^url=(.*)$) {
set $target $1;
}
add_header X-Proxy-Cache $upstream_cache_status;
proxy_pass $target;
proxy_cache ajax_proxy;
proxy_cache_valid 3m;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass umap;
include /srv/umap/uwsgi_params;
}
}