Такое вот программирование на nginx.
$ curl -I localhost:9999/
HTTP/1.1 429 Too Many Requests
Server: nginx/1.12.2
Date: Thu, 14 Nov 2019 21:06:14 GMT
Content-Type: text/html
Content-Length: 185
Connection: close
Retry-After: 100
| server { | |
| listen 9999; | |
| location / { | |
| auth_request /auth; | |
| auth_request_set $auth_status $status; | |
| auth_request_set $retry_after $upstream_http_retry_after; | |
| error_page 500 = @500; | |
| echo 'Hi!\n'; | |
| } | |
| location = /auth { | |
| proxy_pass http://localhost:9998; | |
| } | |
| location @500 { | |
| if ($auth_status = 429) { | |
| add_header Retry-After $retry_after always; | |
| return 429; | |
| } | |
| return 500; | |
| } | |
| } | |
| server { | |
| listen 9998; | |
| add_header Retry-After 100 always; | |
| return 429; | |
| } |