NGINX: Remove inline Lua from template. (#11806)

This commit is contained in:
Ricardo Katz 2024-09-08 18:48:12 -03:00 committed by GitHub
parent ee61440780
commit 6510535ae0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 361 additions and 233 deletions

View file

@ -0,0 +1,2 @@
local balancer = require("balancer")
balancer.balance()

View file

@ -0,0 +1,2 @@
local tcp_udp_balancer = require("tcp_udp_balancer")
tcp_udp_balancer.balance()

View file

@ -0,0 +1,2 @@
local certificate = require("certificate")
certificate.call()

View file

@ -0,0 +1,2 @@
local configuration = require("configuration")
configuration.call()

View file

@ -0,0 +1,2 @@
local tcp_udp_configuration = require("tcp_udp_configuration")
tcp_udp_configuration.call()

View file

@ -0,0 +1,2 @@
local tcp_udp_balancer = require("tcp_udp_balancer")
tcp_udp_balancer.init_worker()

View file

@ -0,0 +1,9 @@
local configuration = require("configuration")
local backend_data = configuration.get_backends_data()
if not backend_data then
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
return
end
ngx.say("OK")
ngx.exit(ngx.HTTP_OK)

View file

@ -0,0 +1,2 @@
local monitor = require("monitor")
monitor.call()

View file

@ -0,0 +1,11 @@
local balancer = require("balancer")
local monitor = require("monitor")
local luaconfig = ngx.shared.luaconfig
local enablemetrics = luaconfig:get("enablemetrics")
balancer.log()
if enablemetrics then
monitor.call()
end

View file

@ -0,0 +1 @@
ngx.var.cache_key = ngx.encode_base64(ngx.sha1_bin(ngx.var.tmp_cache_key))

View file

@ -0,0 +1,2 @@
local lua_ingress = require("lua_ingress")
lua_ingress.header()

View file

@ -0,0 +1,5 @@
local lua_ingress = require("lua_ingress")
local balancer = require("balancer")
lua_ingress.rewrite()
balancer.rewrite()

View file

@ -0,0 +1,24 @@
local request_uri = ngx.var.request_uri
local redirect_to = ngx.arg[1]
local luaconfig = ngx.shared.luaconfig
local use_forwarded_headers = luaconfig:get("use_forwarded_headers")
if string.sub(request_uri, -1) == "/" then
request_uri = string.sub(request_uri, 1, -2)
end
local redirectScheme = ngx.var.scheme
local redirectPort = ngx.var.server_port
if use_forwarded_headers then
if ngx.var.http_x_forwarded_proto then
redirectScheme = ngx.var.http_x_forwarded_proto
end
if ngx.var.http_x_forwarded_port then
redirectPort = ngx.var.http_x_forwarded_port
end
end
return string.format("%s://%s:%s%s", redirectScheme,
redirect_to, redirectPort, request_uri)