-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.tmpl
More file actions
75 lines (60 loc) · 2.18 KB
/
Copy pathnginx.tmpl
File metadata and controls
75 lines (60 loc) · 2.18 KB
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
worker_processes ${{NGINX_WORKER_PROCESSES}}; # can be set by kong.conf
daemon ${{NGINX_DAEMON}}; # can be set by kong.conf
pid pids/nginx.pid; # this setting is mandatory
error_log logs/error.log ${{LOG_LEVEL}}; # can be set by kong.conf
events {
#worker_connections 1024;
}
http {
proxy_cache_path /tmp/nginx_cache_image levels=1:2 keys_zone=image_cache:10M max_size=100M inactive=40d;
# include default Kong Nginx config
include 'nginx-kong.conf';
server {
listen 79;
return 301 https://$host$request_uri;
}
server {
listen 80;
charset UTF-8;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
resolver 127.0.0.11;
set $images 'image-api.gdl-local';
set $api_gateway '127.0.0.1:8000';
location ~* ^/image-api/(v.*)/raw/(.*) {
set_by_lua_block $gdl_env { return os.getenv("GDL_ENVIRONMENT") }
set $s3_bucket 's3.eu-central-1.amazonaws.com/$gdl_env.images.gdl';
set $url_image 'http://$images/image-api/$1/raw/$2$is_args$args';
if ($args = '') {
set $url_image 'https://$s3_bucket/$2?';
}
proxy_set_header Referer 'gdl_proxy';
proxy_pass $url_image;
proxy_cache image_cache;
proxy_cache_key "$proxy_host$uri$is_args$args";
proxy_cache_valid 30d;
proxy_cache_lock on;
proxy_cache_use_stale error invalid_header timeout updating;
proxy_http_version 1.1;
expires 30d;
}
location ~* ^/health$ {
add_header 'Content-Length' 0;
return 200;
}
location ~* ^/([^/]*) {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Forwarded "for=$remote_addr;proto=$http_x_forwarded_proto";
proxy_set_header X-Forwarded-Prefix /$1;
proxy_pass http://$api_gateway;
}
}
}