Nginx 直接返回数据

Nginx About 501 words

示例

location /hello {
    default_type text/html;
    add_header Content-Type 'text/html; charset=utf-8';
    return 200 '你好';
}

返回 JSON

location /get_json {
    default_type application/json;
    return 200 '{"status":"success","result":"nginx json"}';
}

应用场景

微信公众号/小程序验证域名

微信公众号/小程序下载下来的文件,拷贝文件中的文字,配置到Nginx

location  /MP_verify_xxxxxxxxxxxxxxxx.txt {
  default_type text/html;
  return 200 'xxxxxxxxxxxxxxxx';
}

Kubernetes 探针

location /actuator/health {
   access_log off;
   return 200 "Up\n";
}
Views: 540 · Posted: 2024-01-24

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh