-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
93 lines (70 loc) · 2.24 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
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
daemon off;
http {
lua_package_path "/opt/redx/lua/src/lib/plugins/?.lua;/opt/redx/lua/src/lib/?.lua;/opt/redx/lua/conf/?.lua;/opt/redx/lua/src/bin/?.lua;;;";
lua_package_cpath ";;";
init_by_lua_file "/opt/redx/lua/src/bin/init_redx.lua";
error_log /dev/stdout;
access_log /dev/stdout;
upstream fallback {
server 192.168.50.2:7700;
}
server {
# API
listen 8081;
lua_code_cache on;
location / {
default_type application/json;
content_by_lua '
require("lapis").serve("api")
';
}
}
server {
# this server is meant to expose only the health check api endpoint so it can be exposed it to the world,
# while still securing the rest of the API.
listen 8082;
location = /health {
proxy_pass http://127.0.0.1:8081/health;
proxy_set_header Host $host;
}
}
server {
# MAIN
listen 80;
listen 443;
lua_code_cache on;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 300s;
proxy_connect_timeout 3s;
proxy_buffering off;
rewrite_log on;
# set default upstream in case reference not found in redis
set $upstream 'fallback';
location / {
access_by_lua '
require("lapis").serve("main")
';
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For "$proxy_add_x_forwarded_for";
proxy_intercept_errors on;
error_page 502 504 @fallback;
proxy_pass http://$upstream;
}
location @fallback {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For "$proxy_add_x_forwarded_for";
proxy_pass http://fallback;
}
}
}