Created
September 26, 2020 16:22
-
-
Save 123ish/dea083b0181b5a3b114b34c3975623f9 to your computer and use it in GitHub Desktop.
.platform/nginx/conf.d/00_rate_limit.conf
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
# Example of nginx configulation file for AL2 Amazon Elastic Beanstalk | |
# your vpc subnet where ELB resides in | |
set_real_ip_from 10.0.0.0/8; | |
# Then you have the configuration like this. Please note real_ip_header and real_ip_recursive have | |
# to be placed in the bottom of the IP list otherwise the module will not work properly(I’ve spent so much time on this). | |
real_ip_header X-Forwarded-For; | |
real_ip_recursive on; | |
# limit the number of connections to 30 per min and allow to burst to 10 | |
limit_req_zone $http_x_forwarded_for zone=application:10m rate=5r/m; | |
limit_req zone=application burst=10 nodelay; | |
limit_req_status 429; | |
limit_conn_status 429; | |
error_page 429 /429; |
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
# Example of the old nginx configulation file for Amazon Linux 2018 Amazon Elastic Beanstalk | |
files: | |
"/etc/nginx/conf.d/01b_rate-limit.conf": | |
owner: root | |
group: root | |
mode: "000644" | |
content: | | |
# your vpc subnet where ELB resides in | |
set_real_ip_from 10.0.0.0/8; | |
# Then you have the configuration like this. Please note real_ip_header and real_ip_recursive have | |
# to be placed in the bottom of the IP list otherwise the module will not work properly(I’ve spent so much time on this). | |
real_ip_header X-Forwarded-For; | |
real_ip_recursive on; | |
# limit the number of connections to 30 per min and allow to burst to 10 | |
limit_req_zone $http_x_forwarded_for zone=application:10m rate=5r/m; | |
limit_req zone=application burst=10 nodelay; | |
limit_req_status 429; | |
limit_conn_status 429; | |
error_page 429 /429; | |
container_commands: | |
02_reload_nginx: | |
command: "sudo service nginx reload" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment