diff --git a/.gitignore b/.gitignore index 3697d8d54910..c06fa2ce3169 100644 --- a/.gitignore +++ b/.gitignore @@ -77,4 +77,3 @@ boofuzz-results/ # release tar package *.tgz release/* -html/* diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua index 0816faef9633..69dcfe7d224c 100644 --- a/apisix/cli/ngx_tpl.lua +++ b/apisix/cli/ngx_tpl.lua @@ -352,7 +352,9 @@ http { location @50x.html { set $from_error_page 'true'; - try_files /50x.html $uri; + content_by_lua_block { + require("apisix.error_handling").handle_500() + } } } {% end %} @@ -434,7 +436,9 @@ http { location @50x.html { set $from_error_page 'true'; - try_files /50x.html $uri; + content_by_lua_block { + require("apisix.error_handling").handle_500() + } } } {% end %} @@ -683,7 +687,9 @@ http { location @50x.html { set $from_error_page 'true'; - try_files /50x.html $uri; + content_by_lua_block { + require("apisix.error_handling").handle_500() + } header_filter_by_lua_block { apisix.http_header_filter_phase() } diff --git a/apisix/cli/ops.lua b/apisix/cli/ops.lua index 73166a6a13d8..4c1c46af651c 100644 --- a/apisix/cli/ops.lua +++ b/apisix/cli/ops.lua @@ -19,7 +19,6 @@ local etcd = require("apisix.cli.etcd") local util = require("apisix.cli.util") local file = require("apisix.cli.file") local ngx_tpl = require("apisix.cli.ngx_tpl") -local html_page = require("apisix.cli.html_page") local profile = require("apisix.core.profile") local template = require("resty.template") local argparse = require("argparse") @@ -683,14 +682,6 @@ Please modify "admin_key" in conf/config.yaml . if not ok then util.die("failed to update nginx.conf: ", err, "\n") end - - local cmd_html = "mkdir -p " .. env.apisix_home .. "/html" - util.execute_cmd(cmd_html) - - local ok, err = util.write_file(env.apisix_home .. "/html/50x.html", html_page) - if not ok then - util.die("failed to write 50x.html: ", err, "\n") - end end diff --git a/apisix/cli/html_page.lua b/apisix/error_handling.lua similarity index 84% rename from apisix/cli/html_page.lua rename to apisix/error_handling.lua index f262ad8c226c..524c46b2c7a7 100644 --- a/apisix/cli/html_page.lua +++ b/apisix/error_handling.lua @@ -14,9 +14,12 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- +local core = require("apisix.core") +local ngx = ngx -return [=[ - + +local _M = {} +local page_500 = [[
@@ -35,5 +38,13 @@ return [=[You can report issue to APISIX
Faithfully yours, APISIX.
- -]=] +