-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnginx.conf
More file actions
76 lines (58 loc) · 2.24 KB
/
nginx.conf
File metadata and controls
76 lines (58 loc) · 2.24 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
worker_processes ${{NUM_WORKERS}};
error_log stderr notice;
daemon off;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
${{RESOLVER_STRING}}
# pre-load list of fhir-supported resources so it's available to lapis before starting
# not done inside lapis as lapis doesn't support running functions before `return app'
# keep track of whenever we've intialised fhirbase in nginx shared memory, if_modified_since
# with code cache off, init_by_lua_block is run on every request (and shared memory, on the
# other hand, persists)
lua_shared_dict fhirbase 12k;
# keeps track of which resources this server knows about
lua_shared_dict known_resources 36k;
init_by_lua_block {
local fhirbase_initialised = ngx.shared.fhirbase:get("initialised")
if fhirbase_initialised then return end
local saved, err = ngx.shared.fhirbase:set("initialised", true)
if not saved then ngx.log(ngx.WARN, "Could not flag that fhirbase has been initialised; this will have a performance impact as fhirbase might be initialised when unnecessary. Nginx error was: ", err) end
local init = require("views.init")
local known_resources = init.get_fhirbase_resources()
init.setup_fhirbase(known_resources)
init.setup_app_dryfhir(known_resources, ngx.shared.known_resources)
print([[fhirbase setup on `]]..init.config.postgres.database..[[` database complete]])
}
server {
listen ${{PORT}};
lua_code_cache ${{CODE_CACHE}};
location / {
default_type text/html;
content_by_lua '
-- bug in nginx - does not allow you to handle If-Match header yourself
-- can\'t handle it below in header_filter either, seems to be too late
local if_match = ngx.req.get_headers()["If-Match"]
if if_match then
ngx.req.clear_header("If-Match")
ngx.req.set_header("If-Match-DryFHIR", if_match)
end
require("lapis").serve("app")
';
header_filter_by_lua_block {
if ngx.header["Content-Type"] == "${{NO_RETURN_CONTENT_TYPE}}" then
ngx.header["Content-Type"] = nil
end
}
}
location /static/ {
alias static/;
}
location /favicon.ico {
alias static/favicon.ico;
}
}
}