-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
76 lines (62 loc) · 1.8 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
worker_processes 1;
error_log logs/error.log info;
events {
worker_connections 1024;
}
env JWT_SECRET;
http {
include mime.types;
default_type application/octet-stream;
lua_package_path '/app/lib/?.lua;;';
server {
listen 80 default_server;
listen 443 default_server ssl;
server_name _;
server_tokens off;
access_log off;
more_clear_headers 'Server' 'Connection';
add_header X-Echo-Request-URI $request_uri;
ssl_certificate /etc/ssl/selfsigned/cert.pem;
ssl_certificate_key /etc/ssl/selfsigned/key.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
location ~ /status/(\d\d\d) {
access_by_lua_block {
ngx.exit(ngx.var[1])
}
}
location = /jwt {
access_by_lua_block {
local cjson = require("cjson")
local jwt = require("resty.jwt")
ngx.req.read_body()
local data = ngx.req.get_body_data()
local response = jwt.load_jwt(os.getenv("JWT_SECRET"), data)
ngx.header["Content-Type"] = "application/json"
ngx.print(cjson.encode(response))
}
}
location = /websocket {
# version 1.1;
add_header Upgrade $http_upgrade;
add_header Connection "upgrade";
add_header Host $host;
content_by_lua_file '/app/lib/websocket.lua';
}
location / {
access_by_lua_block {
local headers = ngx.req.get_headers()
for k, v in pairs(headers) do
ngx.header[k] = v
end
}
echo "\r";
echo_read_request_body;
echo $request_body;
}
}
}