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

mac2022-06-30  34

有时候我们调试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}'; }

 

转载于:https://www.cnblogs.com/itsuibi/p/11515035.html

最新回复(0)