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

 

相关文章:

  • 2021-10-25
  • 2022-01-20
  • 2022-12-23
  • 2021-05-21
  • 2021-07-15
猜你喜欢
  • 2021-05-04
  • 2021-11-09
  • 2022-12-23
  • 2021-05-13
  • 2022-01-30
  • 2021-08-15
相关资源
相似解决方案