Created
January 10, 2018 17:45
-
-
Save sharshenov/367bf7ad677fa80727d166a6cf4b622e to your computer and use it in GitHub Desktop.
Nginx forward proxy with requests rate throttling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
sendfile on; | |
keepalive_timeout 65; | |
gzip on; | |
#limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; | |
limit_req_zone $http_host zone=mylimit:10m rate=1r/s; | |
server { | |
listen 8080; | |
location / { | |
limit_req zone=mylimit burst=9999; | |
resolver 8.8.8.8; | |
proxy_pass http://$http_host$uri$is_args$args; | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment