aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-09-21 23:49:56 +0200
committerKim Alvefur <zash@zash.se>2018-09-21 23:49:56 +0200
commit93b55928f68992edb76946917e44e59deaf5603c (patch)
tree34bf40e8c61c0c4d47880abeaa7a6283890a165f
parent91c5bd7853a6b40c87674399fce3a1f1f58e4754 (diff)
downloadprosody-93b55928f68992edb76946917e44e59deaf5603c.tar.gz
prosody-93b55928f68992edb76946917e44e59deaf5603c.zip
mod_http: Support global HTTP modules
Such modules simply ignore the Host header and always handle the same path.
-rw-r--r--plugins/mod_http.lua21
1 files changed, 16 insertions, 5 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua
index 28d5d2d4..0eef6d63 100644
--- a/plugins/mod_http.lua
+++ b/plugins/mod_http.lua
@@ -38,7 +38,11 @@ local function get_http_event(host, app_path, key)
if app_path == "/" and path:sub(1,1) == "/" then
app_path = "";
end
- return method:upper().." "..host..app_path..path;
+ if host == "*" then
+ return method:upper().." "..app_path..path;
+ else
+ return method:upper().." "..host..app_path..path;
+ end
end
local function get_base_path(host_module, app_name, default_app_path)
@@ -85,7 +89,10 @@ function moduleapi.http_url(module, app_name, default_path)
end
function module.add_host(module)
- local host = module:get_option_string("http_host", module.host);
+ local host = module.host;
+ if host ~= "*" then
+ host = module:get_option_string("http_host", host);
+ end
local apps = {};
module.environment.apps = apps;
local function http_app_added(event)
@@ -144,12 +151,16 @@ function module.add_host(module)
module:handle_items("http-provider", http_app_added, http_app_removed);
- server.add_host(host);
- function module.unload()
- server.remove_host(host);
+ if host ~= "*" then
+ server.add_host(host);
+ function module.unload()
+ server.remove_host(host);
+ end
end
end
+module.add_host(module); -- set up handling on global context too
+
local trusted_proxies = module:get_option_set("trusted_proxies", { "127.0.0.1", "::1" })._items;
local function get_ip_from_request(request)