直接返回文本:
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":"服务正在升级,请稍后再试……"}';
}
返回变量值
location ~ \.php$ {
default_type text/plain;
return 502 "$document_root$fastcgi_script_name";
}
该文讲述了如何在服务器配置中,针对location路径,设置不同的内容类型(text/plain,text/html,application/json)来返回502错误信息,提示用户服务正在升级。示例中还包括了返回PHP脚本路径的变量值。
1987

被折叠的 条评论
为什么被折叠?



