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; }
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.