# Delay error 503 code with ngx\_http\_delay

**URL:** <https://www.ruby-forum.com/t/delay-error-503-code-with-ngx-http-delay/220873>\
**Category:** NGINX\
**Created:** [June 22, 2012, 8:09pm UTC](https://www.ruby-forum.com/t/delay-error-503-code-with-ngx-http-delay/220873 "2012-06-22T20:09:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 22, 2012, 8:09pm UTC](https://www.ruby-forum.com/t/delay-error-503-code-with-ngx-http-delay/220873/1 "2012-06-22T20:09:36Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![CM\_Fields](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/439d5e/32.png) [@CM\_Fields](https://www.ruby-forum.com/u/CM_Fields)\
**Post date:** [June 23, 2012, 4:19pm UTC](https://www.ruby-forum.com/t/delay-error-503-code-with-ngx-http-delay/220873/2 "2012-06-23T16:19:28Z")

</div>

Maybe the location should be changed, like this:

location ~ //.

Be careful about the slash before the dot(.)
