fix for snippets update
[wolnelektury.git] / scripts / nginx.conf
1 server {
2     listen 80;
3
4     access_log off;
5     error_log /dev/stderr warn;
6
7     client_max_body_size 4G;
8     send_timeout 300s;
9     proxy_buffers 16 16k;
10     proxy_buffer_size 32k;
11
12     location /static/ {
13         root /app/var;
14         expires 30d;
15     }
16
17     location /media/ {
18         root /app/var;
19         expires 30d;
20     }
21     location ~ ^/media/.*\.(mp3|ogg|daisy\.zip)$ {
22         add_header Content-Disposition "attachment";
23     }
24     location ~ ^/media/.*\.txt$ {
25         add_header Content-Type "text/plain; charset=utf-8";
26     }
27     location ~ ^/media/book/(pdf|epub|mobi|fb2|cover|xml)/ {
28         # kill cache
29         add_header Last-Modified $date_gmt;
30         add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
31         if_modified_since off;
32         expires off;
33         etag off;
34     }
35
36     location /api/ {
37         add_header 'Access-Control-Allow-Origin' '*' always;
38         add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE' always;
39         add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
40         add_header 'Access-Control-Expose-Headers' 'Link' always;
41
42         if ($request_method = OPTIONS) {
43             return 204;
44         }
45
46         proxy_set_header Accept-Language "";
47         proxy_set_header Host $host;
48         proxy_pass http://web:8000;
49     }
50     location / {
51         root /app/var/static/root;
52         try_files $uri @backend;
53     }
54
55     location @backend {
56         proxy_set_header Accept-Language "";
57         proxy_set_header Host $host;
58         proxy_pass http://web:8000;
59     }
60 }