feat: Made rate limit via nginx
Some checks are pending
Create and publish a Docker image / build-and-push-server (push) Waiting to run
Create and publish a Docker image / build-and-push-chart (push) Waiting to run
Create and publish a Docker image / build-and-push-CR (push) Waiting to run
Deploy docs / deploy (push) Waiting to run

This commit is contained in:
Данил 2024-11-17 14:53:13 +03:00
parent bb0c22bb1d
commit 29f185adcf

View file

@ -1,6 +1,9 @@
events { } events { }
http { http {
limit_req_zone $binary_remote_addr zone=kekkai:10m rate=10r/s;
# Change the number '10' to your own, to change the threshold number for rate limit
upstream server_backend { upstream server_backend {
server server:3000; server server:3000;
} }
@ -13,8 +16,11 @@ http {
listen 80; listen 80;
server_name localhost; # Your domain server_name localhost; # Your domain
limit_req zone=kekkai;
location / { location / {
limit_req zone=kekkai burst=4;
proxy_pass http://server_backend; proxy_pass http://server_backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -23,6 +29,8 @@ http {
} }
location /api/configuration { location /api/configuration {
limit_req zone=kekkai burst=4;
proxy_pass http://server_backend; proxy_pass http://server_backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -31,6 +39,8 @@ http {
} }
location /api/getChart { location /api/getChart {
limit_req zone=kekkai burst=4;
proxy_pass http://chart_backend; proxy_pass http://chart_backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -39,6 +49,8 @@ http {
} }
location /static/chart { location /static/chart {
limit_req zone=kekkai burst=4;
proxy_pass http://chart_backend; proxy_pass http://chart_backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -54,7 +66,11 @@ http {
ssl_certificate /etc/nginx/ssl/fullchain.pem; ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem; ssl_certificate_key /etc/nginx/ssl/privkey.pem;
limit_req zone=kekkai;
location / { location / {
limit_req zone=kekkai burst=4;
proxy_pass http://server_backend; proxy_pass http://server_backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -63,6 +79,8 @@ http {
} }
location /api/configuration { location /api/configuration {
limit_req zone=kekkai burst=4;
proxy_pass http://server_backend; proxy_pass http://server_backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -71,6 +89,8 @@ http {
} }
location /api/getChart { location /api/getChart {
limit_req zone=kekkai burst=4;
proxy_pass http://chart_backend; proxy_pass http://chart_backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -79,6 +99,8 @@ http {
} }
location /static/chart { location /static/chart {
limit_req zone=kekkai burst=4;
proxy_pass http://chart_backend; proxy_pass http://chart_backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;