Home > Backend Development > PHP Tutorial > Nginx HTTP return status code modification

Nginx HTTP return status code modification

WBOY
Release: 2016-07-29 09:05:18
Original
3049 people have browsed it

Due to the limit_req traffic limit being set in the nginx configuration, many requests return 503 error codes. Under the current limit conditions, in order to improve user experience, we hope to return normal Code 200 and return information about frequent operations:

location  /test {
  ... 
  limit_req z burst=1 nodelay; 
  error_page 503 =200 /dealwith_503?callback=$arg_callback;
}
location /dealwith_503{ 
  set $ret_body '{"code": "V00006","msg": "操作太频繁了,请坐下来喝杯茶。"}';
   if ( $arg_callback != "" ) 
   { 
       return 200 'try{$arg_callback($ret_body)}catch(e){}'; 
   } 
   return 200 $ret_body; 
}
Copy after login


The above introduces the modification of Nginx HTTP return status code, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template