Skip to content

Commit 3d2a68a

Browse files
committed
1 parent 9ae2222 commit 3d2a68a

23 files changed

+529
-491
lines changed

‎conf/http/api/set_keyval.conf

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load_module modules/ngx_http_js_module.so;
22

3-
events { }
3+
events { }
44

55
http {
66
js_path "/etc/nginx/njs/";
@@ -10,19 +10,20 @@ http {
1010
keyval_zone zone=foo:10m;
1111

1212
server {
13-
listen 80;
13+
listen 80;
1414

15-
location /keyval {
16-
js_content main.set_keyval;
17-
}
15+
location /keyval {
16+
js_content main.set_keyval;
17+
}
1818

19-
location /api {
20-
internal;
21-
api write=on;
22-
}
19+
location /api {
20+
internal;
21+
api write=on;
22+
}
23+
24+
location /api/ro {
25+
api;
26+
}
2327

24-
location /api/ro {
25-
api;
26-
}
2728
}
2829
}

‎conf/http/async_var/auth_request.conf

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,50 @@
11
load_module modules/ngx_http_js_module.so;
22

3-
events { }
3+
events { }
44

55
http {
6-
js_path "/etc/nginx/njs/";
6+
js_path "/etc/nginx/njs/";
77

8-
js_import main from http/async_var/auth_request.js;
8+
js_import main from http/async_var/auth_request.js;
99

10-
server {
11-
listen 80;
10+
server {
11+
listen 80;
1212

13-
location /secure/ {
14-
auth_request /fetch_upstream;
15-
auth_request_set $backend $upstream_http_x_backend;
13+
location /secure/ {
14+
auth_request /fetch_upstream;
15+
auth_request_set $backend $upstream_http_x_backend;
1616

17-
proxy_pass http://$backend;
18-
}
17+
proxy_pass http://$backend;
18+
}
1919

20-
location /fetch_upstream {
21-
internal;
20+
location /fetch_upstream {
21+
internal;
2222

23-
proxy_pass http://127.0.0.1:8079;
24-
proxy_pass_request_body off;
25-
proxy_set_header Content-Length "";
26-
proxy_set_header X-Original-URI $request_uri;
27-
}
28-
}
23+
proxy_pass http://127.0.0.1:8079;
24+
proxy_pass_request_body off;
25+
proxy_set_header Content-Length "";
26+
proxy_set_header X-Original-URI $request_uri;
27+
}
2928

30-
server {
31-
listen 127.0.0.1:8079;
29+
}
3230

33-
location / {
31+
server {
32+
listen 127.0.0.1:8079;
33+
34+
location / {
3435
js_content main.choose_upstream;
35-
}
36-
}
37-
38-
server {
39-
listen 127.0.0.1:8081;
40-
return 200 "BACKEND A:$uri\n";
41-
}
42-
43-
server {
44-
listen 127.0.0.1:8082;
45-
return 200 "BACKEND B:$uri\n";
46-
}
36+
}
37+
38+
}
39+
40+
server {
41+
listen 127.0.0.1:8081;
42+
return 200 "BACKEND A:$uri\n";
43+
}
44+
45+
server {
46+
listen 127.0.0.1:8082;
47+
return 200 "BACKEND B:$uri\n";
48+
}
49+
4750
}
Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,52 @@
11
load_module modules/ngx_http_js_module.so;
22

3-
events { }
3+
events { }
44

55
http {
6-
js_path "/etc/nginx/njs/";
6+
js_path "/etc/nginx/njs/";
77

8-
js_import main from http/async_var/js_header_filter.js;
8+
js_import main from http/async_var/js_header_filter.js;
99

10-
server {
11-
listen 80;
10+
server {
11+
listen 80;
1212

13-
location /secure/ {
14-
auth_request /fetch_upstream;
15-
auth_request_set $backend $sent_http_x_backend;
13+
location /secure/ {
14+
auth_request /fetch_upstream;
15+
auth_request_set $backend $sent_http_x_backend;
1616

17-
proxy_pass http://$backend;
18-
}
17+
proxy_pass http://$backend;
18+
}
1919

20-
location /fetch_upstream {
21-
internal;
20+
location /fetch_upstream {
21+
internal;
2222

23-
proxy_pass http://127.0.0.1:8079;
24-
proxy_pass_request_body off;
25-
proxy_set_header Content-Length "";
26-
proxy_set_header X-Original-URI $request_uri;
23+
proxy_pass http://127.0.0.1:8079;
24+
proxy_pass_request_body off;
25+
proxy_set_header Content-Length "";
26+
proxy_set_header X-Original-URI $request_uri;
2727

28-
js_header_filter main.set_upstream;
29-
}
30-
}
28+
js_header_filter main.set_upstream;
29+
}
3130

32-
server {
33-
listen 127.0.0.1:8079;
31+
}
3432

35-
location / {
33+
server {
34+
listen 127.0.0.1:8079;
35+
36+
location / {
3637
js_content main.choose_upstream;
37-
}
38-
}
39-
40-
server {
41-
listen 127.0.0.1:8081;
42-
return 200 "BACKEND A:$uri\n";
43-
}
44-
45-
server {
46-
listen 127.0.0.1:8082;
47-
return 200 "BACKEND B:$uri\n";
48-
}
38+
}
39+
40+
}
41+
42+
server {
43+
listen 127.0.0.1:8081;
44+
return 200 "BACKEND A:$uri\n";
45+
}
46+
47+
server {
48+
listen 127.0.0.1:8082;
49+
return 200 "BACKEND B:$uri\n";
50+
}
51+
4952
}
Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
load_module modules/ngx_http_js_module.so;
22

3-
events { }
3+
events { }
44

55
env SECRET_KEY;
66

77
http {
8-
js_path "/etc/nginx/njs/";
8+
js_path "/etc/nginx/njs/";
99

10-
js_import main from http/authorization/auth_request.js;
10+
js_import main from http/authorization/auth_request.js;
1111

12-
upstream backend {
13-
server 127.0.0.1:8081;
14-
}
12+
upstream backend {
13+
server 127.0.0.1:8081;
14+
}
1515

16-
server {
17-
listen 80;
16+
server {
17+
listen 80;
1818

19-
location /secure/ {
20-
auth_request /validate;
19+
location /secure/ {
20+
auth_request /validate;
2121

22-
proxy_pass http://backend;
23-
}
22+
proxy_pass http://backend;
23+
}
2424

25-
location /validate {
26-
internal;
27-
js_content main.authorize;
28-
}
29-
}
25+
location /validate {
26+
internal;
27+
js_content main.authorize;
28+
}
29+
30+
}
31+
32+
server {
33+
listen 127.0.0.1:8081;
34+
return 200 "BACKEND:$uri\n";
35+
}
3036

31-
server {
32-
listen 127.0.0.1:8081;
33-
return 200 "BACKEND:$uri\n";
34-
}
3537
}
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
load_module modules/ngx_http_js_module.so;
22

3-
events { }
3+
events { }
44

55
env JWT_GEN_KEY;
66

77
http {
8-
js_path "/etc/nginx/njs/";
8+
js_path "/etc/nginx/njs/";
99

10-
js_import utils.js;
11-
js_import main from http/authorization/gen_hs_jwt.js;
10+
js_import utils.js;
11+
js_import main from http/authorization/gen_hs_jwt.js;
1212

13-
js_set $jwt main.jwt;
13+
js_set $jwt main.jwt;
1414

15-
server {
16-
listen 80;
15+
server {
16+
listen 80;
1717

18-
location /version {
19-
js_content utils.version;
20-
}
18+
location /version {
19+
js_content utils.version;
20+
}
2121

22-
location /jwt {
23-
return 200 $jwt;
24-
}
25-
}
22+
location /jwt {
23+
return 200 "$jwt";
24+
}
25+
26+
}
2627
}

‎conf/http/authorization/jwt.conf

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
load_module modules/ngx_http_js_module.so;
22

3-
events { }
3+
events { }
44

55
http {
6-
js_path "/etc/nginx/njs/";
6+
js_path "/etc/nginx/njs/";
77

8-
js_import utils.js;
9-
js_import main from http/authorization/jwt.js;
8+
js_import utils.js;
9+
js_import main from http/authorization/jwt.js;
1010

11-
js_set $jwt_payload_sub main.jwt_payload_sub;
11+
js_set $jwt_payload_sub main.jwt_payload_sub;
1212

13-
server {
14-
listen 80;
13+
server {
14+
listen 80;
1515

16-
location /version {
17-
js_content utils.version;
18-
}
16+
location /version {
17+
js_content utils.version;
18+
}
1919

20-
location /jwt {
21-
return 200 $jwt_payload_sub;
22-
}
23-
}
20+
location /jwt {
21+
return 200 "$jwt_payload_sub";
22+
}
23+
24+
}
2425
}

0 commit comments

Comments
 (0)