delay error 503 code with ngx_http_delay
CM Fields
cmfileds at gmail.com
Fri Jun 22 18:09:06 UTC 2012
I would like to add a small delay to error 503 responses back to the
client. Error code 503 is triggered when a client hits the
"limit_req_zone" of 200 requests per minute.
Maxim's ngx_http_delay looks like the right tool but I think my
configuration, or my understand is wrong. I am using the latest
version of Nginx and have built it from source adding in the
ngx_http_delay from the git repo. The build finished without error and
Nginx daemon starts fine.
I am using the following syntax. My understanding is error 503 will be
trapped and sent to the "abuse503" location. In "location @abuse503"
we sleep for 2 seconds and then return a error code 503 to the client.
As a test I execute "wget http://myserver/.test"
# Test -- deny hidden files
location ~ /\. { error_page 404 503 @abuse503; }
error_page 503 @abuse503;
location @abuse503 {
delay 2s;
return 503;
}
Do I have the syntax correct? Oddly, what I am seeing is a 404 being
returned immediately and not delayed if the file does NOT exist on the
file system.
192.168.0.1 myserver - [22/Jun/2012:13:26:50 -0400] "GET /.test
HTTP/1.1" 404 831 "-" "Wget/1.13.4 (linux-gnu)"
2012/06/22 13:26:50 [error] 4227#0: *60 open()
"/disk/web/htdocs/.test" failed (2: No such file or directory),
client: 192.168.0.1, server: myserver, request: "GET /.test HTTP/1.1",
host: "myserver"
If the file DOES exist a 503 is sent, but no delay.
Thanks for your time.
More information about the nginx
mailing list