geqintan commited on
Commit
1eed954
·
1 Parent(s): 0bfdf1d
Files changed (2) hide show
  1. app.lua +2 -1
  2. nginx.conf +3 -1
app.lua CHANGED
@@ -19,7 +19,8 @@ local api_version, api_pxoxy_pass_url_indicator = uri:match("/?([^/]+)/?(.*)")
19
  ngx.say("api_version: ", api_version)
20
  ngx.say("api_pxoxy_pass_url_indicator: ", api_pxoxy_pass_url_indicator)
21
  pass_url = api_pxoxy_pass_url_indicator
22
- ngx.req.set_header("upstream", pass_url)
 
23
  pass_url = pass_url:gsub("http/", "http://")
24
  pass_url = pass_url:gsub("https/", "https://")
25
  ngx.say("pass_url: ", pass_url)
 
19
  ngx.say("api_version: ", api_version)
20
  ngx.say("api_pxoxy_pass_url_indicator: ", api_pxoxy_pass_url_indicator)
21
  pass_url = api_pxoxy_pass_url_indicator
22
+ local upstream_dict = ngx.shared.upstream_dict
23
+ upstream_dict:set("upstream", pass_url)
24
  pass_url = pass_url:gsub("http/", "http://")
25
  pass_url = pass_url:gsub("https/", "https://")
26
  ngx.say("pass_url: ", pass_url)
nginx.conf CHANGED
@@ -7,6 +7,8 @@ http {
7
  include mime.types;
8
  default_type application/octet-stream;
9
 
 
 
10
  sendfile on;
11
  keepalive_timeout 65;
12
 
@@ -23,7 +25,7 @@ http {
23
  -- ngx.var.proxy_pass = ngx.var.uri
24
  ngx.var.upstream = 'https://baidu.com';
25
  }
26
- proxy_pass $http_upstream;
27
  }
28
  }
29
  }
 
7
  include mime.types;
8
  default_type application/octet-stream;
9
 
10
+ lua_shared_dict upstream_dict 10m;
11
+
12
  sendfile on;
13
  keepalive_timeout 65;
14
 
 
25
  -- ngx.var.proxy_pass = ngx.var.uri
26
  ngx.var.upstream = 'https://baidu.com';
27
  }
28
+ proxy_pass $ngx.shared.upstream_dict["upstream"];
29
  }
30
  }
31
  }