The following code is an example of preparing Xavante to virtual host:
-- $SYSCONFDIR/kepler/1.1/xavante/config.lua
require "xavante.filehandler"
require "xavante.cgiluahandler"
require "xavante.redirecthandler"
local function makerules(webDir)
return {
{ -- URI remapping example
match = "/",
with = xavante.redirecthandler,
params = { "index.lp", "index.lua", "index.http" }
},
{ -- filehandler example
match = "/*",
with = xavante.filehandler,
params = { baseDir = webDir }
},
{ -- cgiluahandler example
match = { "/*.lp", "/*.lua" },
with = xavante.cgiluahandler.makeHandler(webDir)
},
}
end
-- Displays a message in the console with the used ports
xavante.start_message(function (ports)
local date = os.date "[%Y-%m-%d %H:%M:%S]"
print(
("%s Xavante started on port(s) %s"):format(
date,
table.concat(ports, ", ")
)
)
end)
xavante.HTTP {
server = { host = "*", port = 8080 },
defaultHost = {
rules = makerules(XAVANTE_WEB)
},
--virtualhosts = {
-- ["www.client1.com"] = { rules = makerules "/home/client1" },
-- ["www.client2.com"] = { rules = makerules "/home/client2" },
-- ["www.client3.com"] = { rules = makerules "/home/client3" },
--},
}