-
Notifications
You must be signed in to change notification settings - Fork 1
/
nginx.conf
102 lines (83 loc) · 4.12 KB
/
nginx.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
load_module modules/ngx_http_image_filter_module.so;
user nginx;
worker_processes auto;
error_log /dev/stderr warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
# use debug level to debug proxy pass, rewrites and other nginx internals
# error_log /dev/stderr debug;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
proxy_cache_path /nginx-cache/ levels=1:2 keys_zone=STATIC:10m max_size=500m;
server {
# use the nginx proxy cache defined above in HTTP block
proxy_cache STATIC;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
if ($uri ~ "^/([1-9][0-9]{0,2})x/") {
set $width $1;
set $height -;
}
if ($uri ~ "^/x([1-9][0-9]{0,2})/") {
set $width -;
set $height $1;
}
if ($uri ~ "^/([1-9][0-9]{0,2})x([1-9][0-9]{0,2})/") {
set $width $1;
set $height $2;
}
# Proxy new panoptes-uploads-staging requests to Azure storage
# e.g. https://panoptes-uploads-staging.zooniverse.org/workflow_attached_image/704a79c1-e728-4ab3-828d-e398fba69ec3.jpeg
location ~ "^/[0-9]{0,3}x[0-9]{0,3}/panoptes-uploads-staging.zooniverse.org/.+$" {
rewrite "^/[0-9]{0,3}x[0-9]{0,3}/panoptes-uploads-staging.zooniverse.org(/.*)$" $1 break;
resolver 8.8.8.8;
proxy_pass https://panoptesuploadsstaging.blob.core.windows.net/public$uri?$query_string;
proxy_set_header Host panoptesuploadsstaging.blob.core.windows.net;
image_filter_buffer 10M;
image_filter resize $width $height;
}
# Proxy old panoptes-uploads staging requests to Azure storage
# e.g. https://panoptes-uploads.zooniverse.org/staging/workflow_attached_image/362d0a60-84a1-41db-9ea9-a42789f492c8.jpeg
location ~ "^/[0-9]{0,3}x[0-9]{0,3}/panoptes-uploads.zooniverse.org/staging/.+$" {
rewrite "^/[0-9]{0,3}x[0-9]{0,3}/panoptes-uploads.zooniverse.org/staging(/.*)$" $1 break;
resolver 8.8.8.8;
proxy_pass https://panoptesuploadsstaging.blob.core.windows.net/public$uri?$query_string;
proxy_set_header Host panoptesuploadsstaging.blob.core.windows.net;
image_filter_buffer 10M;
image_filter resize $width $height;
}
# Proxy panoptes-uploads production requests to Azure storage
# e.g. https://panoptes-uploads.zooniverse.org/production/workflow_attached_image/c3303c4d-28b2-453c-882c-63a95a5c41bc.jpeg
# https://panoptes-uploads.zooniverse.org/workflow_attached_image/6769554f-9079-41c8-acfc-393737a4972f.jpeg
location ~ "^/[0-9]{0,3}x[0-9]{0,3}/panoptes-uploads.zooniverse.org/.+$" {
rewrite "^/[0-9]{0,3}x[0-9]{0,3}/panoptes-uploads.zooniverse.org(?:/production)?(/.*)$" $1 break;
resolver 8.8.8.8;
proxy_pass https://panoptesuploads.blob.core.windows.net/public$uri?$query_string;
proxy_set_header Host panoptesuploads.blob.core.windows.net;
image_filter_buffer 10M;
image_filter resize $width $height;
}
# proxy all other requests to the azure zoonversestatic storage account, $web container
location / {
rewrite "^/([0-9]{0,3}x[0-9]{0,3})(/.*)$" $2 break;
resolver 8.8.8.8;
proxy_http_version 1.1;
proxy_pass https://zooniversestatic.z13.web.core.windows.net$uri?$query_string;
proxy_set_header Host zooniversestatic.z13.web.core.windows.net;
image_filter_buffer 10M;
image_filter resize $width $height;
}
}
}