Skip to content

Instantly share code, notes, and snippets.

@alexeyten
Created November 14, 2019 21:06
Show Gist options
  • Save alexeyten/a91e8d57267e212f677dd2ed41832604 to your computer and use it in GitHub Desktop.
Save alexeyten/a91e8d57267e212f677dd2ed41832604 to your computer and use it in GitHub Desktop.

Такое вот программирование на 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment