Skip to content

Instantly share code, notes, and snippets.

@insom insom/mod_iweb.lua
Created Jun 10, 2016

Embed
What would you like to do?
mod_iweb but in LUA
require "apache2"
require "socket"
suffix = ".iwebcloud.co.uk"
function strip(hn)
local v = string.gsub(hn, suffix, "")
return string.match(v, "%w+%.cms")
end
function mapper(r)
ip, t = socket.dns.toip(r.headers_in.Host)
if string.find(t.name, suffix) then
r.filename = string.format("proxy:http://%s%s", strip(t.name), r.uri)
r.handler = "proxy-server"
r.proxyreq = apache2.PROXYREQ_REVERSE
return apache2.OK
else
return apache2.DECLINED
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.