-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathdir_data.conf
109 lines (97 loc) · 3.32 KB
/
dir_data.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# The edit directory. $editorfile may be overridden by the includer.
if ($editorfile = '') {
set $editorfile "editor";
}
location ~ ^/edit(?<filepath>/[^\?]*) {
if ($http_user_agent ~ (bot|agent|spider|crawler|extractor|externalhit)) {
return 302 /print$filepath;
}
root /srv/$site/content;
ssi on;
add_header Access-Control-Allow-Origin *;
add_header X-XSS-Protection 0;
try_files /$editorfile.html =404;
}
# JSON data save
location /save/ {
if ($http_user_agent ~ (bot|agent|spider|crawler|extractor|externalhit)) {
return 403;
}
if ($owner ~ ^[^a-z]|^$) {
add_header Content-Type application/json;
return 200 "{\"error\":\"Can not save in this domain.\"}";
}
proxy_pass http://service_node;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
# JSON data load
location /load/ {
proxy_pass http://service_node;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
# Run thumbnails.
location ~ ^/thumb(?P<dir>/|/.*/)(?P<file>.*\.png)$ {
add_header Access-Control-Allow-Origin *;
add_header X-XSS-Protection 0;
add_header Cache-Control "public, max-age=3600";
root /srv/$site/data/$owner;
try_files /$dir/.thumb/$file =404;
error_page 404 = @thumb_fallback;
}
# Run directories, trying index.html before falling back to /dir.html.
location ~ ^/home(?P<dir>/|/.*/)$ {
add_header Access-Control-Allow-Origin *;
add_header X-XSS-Protection 0;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
root /srv/$site/data/$owner;
try_files $dir/index.html /dir.html;
error_page 404 = @home_fallback;
}
# Run files, with an optimization for known static file types.
location ~ ^/home/(?P<file>.*\.(?:js|css|html|txt|xml|json|png|gif|svg|jpg|jpeg|ico|bmp|pdf))$ {
add_header Access-Control-Allow-Origin *;
add_header X-XSS-Protection 0;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
root /srv/$site/data/$owner;
try_files /$file =404;
error_page 404 = @home_fallback;
}
# Bail out of optimization if a file can't be found.
location @home_fallback {
proxy_pass http://service_node;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
# Bail out of thumbnail optimization if a file can't be found.
location @thumb_fallback {
proxy_pass http://service_node;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
# Run files without optimization.
location ~ ^/home/ {
proxy_pass http://service_node;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
# Raw code printout.
location /code/ {
proxy_pass http://service_node;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
# Raw code printout with line numbers.
location /print/ {
proxy_pass http://service_node;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}