-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx-template.conf
More file actions
118 lines (96 loc) · 3.63 KB
/
nginx-template.conf
File metadata and controls
118 lines (96 loc) · 3.63 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
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
env EMIL_IMAGE_PATH;
env EMIL_EMULATOR_REPO_PATH;
env EMIL_ENV_REPO_PATH;
env EMIL_ROM_REPO_PATH;
env EMIL_CHECKPOINT_REPO_PATH;
env EMIL_OBJECT_REPO_PATH;
env EMIL_COMPONENT_REPO_PATH;
worker_processes 8;
error_log /dev/stdout error;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
keepalive_timeout 65;
sendfile on;
access_log /dev/stdout;
# resolver-cache definition
proxy_cache_path /var/cache/nginx/resolver
levels=1:2 keys_zone=resolver-cache:8m
max_size=1g inactive=1h use_temp_path=off;
server {
listen 8080;
resolver 127.0.0.11 ipv6=off;
{% if resolver_cache_kind == 'slice' %}
slice {{ resolver_cache_slice_size }};
proxy_set_header Range $slice_range;
{% endif %}
proxy_http_version 1.1;
proxy_pass $target;
add_header X-Cache-Status $upstream_cache_status;
# custom cache config
proxy_cache data-cache;
{% if resolver_cache_kind == 'slice' %}
proxy_cache_key $request_method+$target+$slice_range;
{% else %}
proxy_cache_key $request_method+$target;
{% endif %}
proxy_cache_valid 200 206 24h;
proxy_cache_convert_head off;
proxy_cache_lock on;
proxy_cache_lock_timeout 0s;
proxy_cache_lock_age 2h;
}
}
server {
listen 8082;
resolver 127.0.0.11 ipv6=off;
{% endif %}
# custom cache config
proxy_cache resolver-cache;
proxy_cache_key $request_method+$scheme+$proxy_host$request_uri+$http_authorization;
proxy_cache_valid 301 307 30m;
proxy_cache_convert_head off;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
set baseurl = eaas_protocol + eaas_gw_hostname + eaas_base_url_port %}
# case: emulators
location ~* /emulators/(?<imgid>.+)$ {
root $EMIL_EMULATOR_REPO_PATH;
try_files $uri /emil/emulator-repository/images/$imgid/url$is_args$args;
}
# case: images
location ~* ^/images/(?<imgid>.+)$ {
root $EMIL_ENV_REPO_PATH;
try_files $uri /emil/environment-repository/images/$imgid/url$is_args$args;
}
# case: roms
location ~* ^/roms/(?<imgid>.+)$ {
root $EMIL_ROM_REPO_PATH;
try_files $uri /emil/environment-repository/roms/$imgid/url$is_args$args;
}
# case: checkpoints
location ~* ^/checkpoints/(?<imgid>.+)$ {
root $EMIL_CHECKPOINT_REPO_PATH;
try_files $uri /emil/environment-repository/checkpoints/$imgid/url$is_args$args;
}
# case: objects
location ~* ^/objects/(?<archive>[^/]+)/(?<object>[^/]+)/(?<subres>.+)$ {
root $EMIL_OBJECT_REPO_PATH/$archive/objects/$object/resources;
try_files $uri /emil/object-repository/archives/$archive/objects/$object/resources/$subres/url$is_args$args;
}
# case: component-resources
location ~* /components/(?<compid>[^/]+)/(?<kind>[^/]+)/(?<subres>.+)$ {
root $EMIL_COMPONENT_REPO_PATH/$compid/$kind;
try_files $uri /emil/components/$compid/$kind/$subres/url;
}
# case: resources with embedded access-tokens
location ~* ^/t/(?<token>[^/]+)/(?<subres>.+)$ {
proxy_cache_key $request_method+$scheme+$proxy_host$request_uri;
set proxyport = '8080'
proxy_pass http://127.0.0.1:{{ proxyport }}/$subres$is_args$args;
proxy_set_header Authorization "Bearer $token";
}
}
}