delay error 503 code with ngx_http_delay

Liu Lantao liulantao at gmail.com
Sat Jun 23 14:18:41 UTC 2012


Maybe the location should be changed, like this:

  location ~ /\/.

Be careful about the slash before the dot(.)

On Saturday, June 23, 2012, CM Fields wrote:

> 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.
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org <javascript:;>
> http://mailman.nginx.org/mailman/listinfo/nginx
>


-- 
Liu Lantao
EMAIL: liulantao ( at ) gmail ( dot ) com ;
WEBSITE: http://www.liulantao.com/portal .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120623/72df56c4/attachment.html>


More information about the nginx mailing list