目录
[TOC]
location / {
return 502 "服务正在升级,请稍后再试……";
}
直接返回文本
location / {
default_type text/plain;
return 502 "服务正在升级,请稍后再试……";
}
也可以使用 html 标签格式
location / {
default_type text/html;
return 502 "服务正在升级,请稍后再试……";
}
也可以直接返回 json 文本
location / {
default_type application/json;
return 502 '{"status":502,"msg":"服务正在升级,请稍后再试……"}';
}
返回 json
location ~ ^/get_json {
default_type application/json;
return 200 '{"status":"success","result":"nginx json"}';
}
根据请求的 URL 返回不同的字符串
location ~ ^/get*text/article/(.\*)*(\d+).html$ {
default_type text/html;
set $s $1;
set $d $2;
return 200 str:$s$d;
}
location / {
set $upstream_name "10.x.x.x:8711";
more_set_headers 'Content-Type: text/html; charset=utf-8';
return 200 "系统已经迁移至 xz.test.com,相关问题请咨询xxx";
proxy_pass http://$upstream_name;
}