调试location指令时,直接让location输出文本

  • 2019 年 10 月 10 日
  • 笔记

有时候我们调试location指令时希望location指令能够直接输出文本,这样能够方便我们进行调试。这时我们可以使用echo模块实现,但是大多数情况我们没有安装这个模块,那么我们还可以使用另一个方法来实现这个想法

直接返回文本

location / {    default-type text/plain;    return 502 "this is a test message";  }

html标签格式

location / {    default-type text/html;    return 502 "this is a test message";  }

返回json文本

location / {              default_type application/json;              return 502 '{"name":"mayuan","age":18}';          }