Opened 11 years ago

Closed 11 years ago

#309 closed enhancement (fixed)

Support http status code 429 for rate limiting (

Reported by: Adam Brod Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.3.x
Keywords: limit_req Cc:
uname -a: Linux myserver.local 2.6.18-308.24.1.el5xen #1 SMP Tue Dec 4 18:33:26 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.2.4
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
TLS SNI support disabled
configure arguments: --prefix=/etc/nginx/ --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g -m64 -mtune=generic'


We use (and love!) nginx to do rate limiting on calls to some of our servers. We'd love the ability to configure the error that gets returned when customers are rate limited (limit_req module). This message should be configured independently from other server errors.

There is a new draft spec RFC6585 that specifies http status code 429 Too Many Requests which is perfect. Since this is draft many not everybody wants this as the default, but at least being able to configure it would be great.

My understanding is that using error_page 503 = 429 /too-many-requests.html would change the behavior for all 503 responses, which isn't correct. If there is a problem with my server, I don't want to tell customers they are being rate limited.

FYI, I have an open question about this on ServerFault:

Change History (2)

comment:1 by Maxim Dounin, 11 years ago

In nginx, 503 is only generated due to limiting (limit_req, limit_conn), and using "error_page 503 =429 ..." is perfectly ok - at least unless you are using proxy_intercept_errors to change errors returned by an upstream.

comment:2 by Maxim Dounin, 11 years ago

Resolution: fixed
Status: newclosed

In r5118 the limit_req_status and limit_conn_status directives were introduced, allowing to arbitrary redefine status code used by limit_req and limit_conn modules.

Note: See TracTickets for help on using tickets.