Ryan Lane has submitted this change and it was merged.
Change subject: Route requests based on data from Redis
......................................................................
Route requests based on data from Redis
Change-Id: I549958d0370426a3317d053d978b31f8a4fc9aef
---
M modules/labsproxy/files/proxy.lua
1 file changed, 13 insertions(+), 7 deletions(-)
Approvals:
Ryan Lane: Looks good to me, approved
Andrew Bogott: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/modules/labsproxy/files/proxy.lua
b/modules/labsproxy/files/proxy.lua
index 77a73d7..e626712 100644
--- a/modules/labsproxy/files/proxy.lua
+++ b/modules/labsproxy/files/proxy.lua
@@ -1,14 +1,20 @@
-- Lua file run by nginx that does appropriate routing
-- Gets domain name, figures out instance name from it, and routes there
+
+local redis = require 'resty.redis'
+local red = redis:new()
+red:set_timeout(1000)
+
+red:connect('127.0.0.1', 6379)
+
local frontend = ngx.re.match(ngx.var.http_host, "^([^:]*)")[1]
-local instance_match = ngx.re.match(frontend,
"(\\d+)?\\.?([^.]+)\\.proxy\\.wmflabs\\.org$")
-local instance_port = 80
-local instance_name = instance_match[2]
+local backend = red:srandmember('frontend:' .. frontend)
-if instance_match[1] ~= nil then
- instance_port = instance_match[1]
+if backend == ngx.null then
+ -- Handle frontends wihout any configuration in them
+ ngx.exit(404)
end
-ngx.var.backend = "http://" .. instance_name .. ":" .. instance_port
-ngx.var.vhost = instance_name
+ngx.var.backend = backend
+ngx.var.vhost = frontend
--
To view, visit https://gerrit.wikimedia.org/r/78025
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I549958d0370426a3317d053d978b31f8a4fc9aef
Gerrit-PatchSet: 9
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Andrew Bogott <[email protected]>
Gerrit-Reviewer: Ryan Lane <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits