Skip to content

Instantly share code, notes, and snippets.

@tacck
Created September 9, 2016 05:13
Show Gist options
  • Save tacck/c148df36b77dc476ca757ce93d7e217f to your computer and use it in GitHub Desktop.
Save tacck/c148df36b77dc476ca757ce93d7e217f to your computer and use it in GitHub Desktop.
location /lua_return_404 {
set $body "";
rewrite_by_lua '
ngx.exit(404)
';
header_filter_by_lua_block {
local body = "{ \"http_host\": \"" .. ngx.var.http_host .. "\" }"
ngx.var.body = body
local body_length = string.len(body)
ngx.header.content_type = "application/json"
ngx.header.content_length = body_length
}
body_filter_by_lua_block {
ngx.arg[1] = ngx.var.body
ngx.arg[2] = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment