Software /
code /
prosody
Comparison
plugins/mod_http.lua @ 13107:9c4dc1e6d2c9
mod_http: Add way to retrieve internal URL instead of external
This could be of help when configuring reverse proxies, as it is the
internal URL the proxy must point at.
Argument treated as an enum "internal" "external"(default) to allow for
future extensibility.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 May 2023 14:43:45 +0200 |
parent | 13069:45caa4e43775 |
child | 13125:90394be5e6a5 |
comparison
equal
deleted
inserted
replaced
13106:8c762a30eae0 | 13107:9c4dc1e6d2c9 |
---|---|
74 end | 74 end |
75 | 75 |
76 local ports_by_scheme = { http = 80, https = 443, }; | 76 local ports_by_scheme = { http = 80, https = 443, }; |
77 | 77 |
78 -- Helper to deduce a module's external URL | 78 -- Helper to deduce a module's external URL |
79 function moduleapi.http_url(module, app_name, default_path) | 79 function moduleapi.http_url(module, app_name, default_path, mode) |
80 app_name = app_name or (module.name:gsub("^http_", "")); | 80 app_name = app_name or (module.name:gsub("^http_", "")); |
81 | 81 |
82 local external_url = url_parse(module:get_option_string("http_external_url")); | 82 local external_url = url_parse(module:get_option_string("http_external_url")); |
83 if external_url then | 83 if external_url and mode ~= "internal" then |
84 local url = { | 84 local url = { |
85 scheme = external_url.scheme; | 85 scheme = external_url.scheme; |
86 host = external_url.host; | 86 host = external_url.host; |
87 port = tonumber(external_url.port) or ports_by_scheme[external_url.scheme]; | 87 port = tonumber(external_url.port) or ports_by_scheme[external_url.scheme]; |
88 path = normalize_path(external_url.path or "/", true) | 88 path = normalize_path(external_url.path or "/", true) |