-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
147 lines (112 loc) · 4.09 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
user root;
worker_processes 4;
load_module modules/ngx_http_image_filter_module.so;
events {
worker_connections 1024;
}
http {
server {
listen 5000;
# include /etc/nginx/mime.types;
# default_type application/octet-stream;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_vary off;
#gzip_buffers
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/rss+xml application/atom+xml text/javascript application/javascript application/json text/mathml;
gzip_min_length 1000;
gzip_disable MSIE [1-6]\.;
set $bucket "fotoscnet.s3-eu-west-1.amazonaws.com";
location ~ /(.+).jpg/(\d+)x(\d+)cut/ {
rewrite ^/(.+).jpg/(\d+)x(\d+)cut/ /crop.jpeg?width=$2&height=$3&key=$1.jpg break;
proxy_pass http://127.0.0.1:5000;
}
location ~ /(.+).jpg/(\d+)x/$ {
rewrite ^/(.+).jpg/(\d+)x/$ /resize.jpeg?width=$2&key=$1.jpg break;
proxy_pass http://127.0.0.1:5000;
}
location ~ /(.+).jpg/x(\d+)/$ {
rewrite ^/(.+).jpg/x(\d+)/$ /resize.jpeg?height=$2&key=$1.jpg break;
proxy_pass http://127.0.0.1:5000;
}
location ~ /(.+).jpg {
set $key $1.jpg ;
resolver 8.8.8.8;
rewrite ^(.+)/$ $key/ permanent;
proxy_pass http://$bucket/$key;
proxy_intercept_errors on;
proxy_redirect off;
proxy_set_header Host $bucket;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
}
location /favicon.ico {
empty_gif;
access_log off;
log_not_found off;
}
location /healthcheck {
default_type text/plain;
return 200 "OK";
}
location /echo.txt {
if ($arg_width = '') {
set $arg_width -;
}
if ($arg_height = '') {
set $arg_height -;
}
return 200 "$arg_width $arg_height $arg_key";
}
location /crop.jpeg {
resolver 8.8.8.8;
if ($arg_width = '') {
set $arg_width -;
}
if ($arg_height = '') {
set $arg_height -;
}
rewrite ^(.+)/$ $arg_key/ permanent;
proxy_pass http://$bucket/$arg_key;
proxy_intercept_errors on;
proxy_redirect off;
proxy_set_header Host $bucket;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
image_filter crop $arg_width $arg_height;
image_filter_jpeg_quality 75;
image_filter_buffer 8M;
allow 127.0.0.0/8;
deny all;
}
location /resize.jpeg {
resolver 8.8.8.8;
if ($arg_width = '') {
set $arg_width -;
}
if ($arg_height = '') {
set $arg_height -;
}
rewrite ^(.+)/$ $arg_key/ permanent;
proxy_pass http://$bucket/$arg_key;
proxy_intercept_errors on;
proxy_redirect off;
proxy_set_header Host $bucket;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
image_filter resize $arg_width $arg_height;
image_filter_jpeg_quality 75;
image_filter_buffer 8M;
allow 127.0.0.0/8;
deny all;
}
}
}