Skip to content

Commit

Permalink
refactor: optimize nginx configuration for performance and resource m…
Browse files Browse the repository at this point in the history
…anagement
  • Loading branch information
LeonardoMeireles55 committed Feb 5, 2025
1 parent 10c6678 commit 27a0ae3
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
user nginx;
worker_processes 1;
worker_processes auto;
worker_rlimit_nofile 20480;

events {
Expand All @@ -12,27 +12,24 @@ http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
limit_req_zone $binary_remote_addr zone=my_limit:10m rate=10r/s;


keepalive_timeout 30;
keepalive_requests 50;

client_header_buffer_size 4k;
client_body_buffer_size 32m;
client_body_buffer_size 8m;
large_client_header_buffers 2 4k;
client_body_timeout 300s;
client_body_timeout 10s;
client_header_timeout 10s;
send_timeout 10s;
client_max_body_size 100m;

types_hash_max_size 2048;
server_tokens off;

gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_comp_level 5;
gzip_min_length 512;
gzip_types
text/plain
Expand All @@ -42,12 +39,15 @@ http {
text/xml
application/xml
text/javascript
image/svg+xml
image/jpeg
image/png
image/gif
image/webp
image/jpg;
image/svg+xml;

location ~* \.(jpg|jpeg)$ {
root /; # Root directory
try_files $uri =404;
access_log off;
expires 30d;
add_header Cache-Control "public";
}

upstream quality-lab-pro {
least_conn;
Expand Down Expand Up @@ -87,8 +87,6 @@ http {
add_header X-Frame-Options DENY;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;



location /backend/ {
proxy_pass http://quality-lab-pro/;
Expand All @@ -99,10 +97,7 @@ http {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

client_max_body_size 100m;
client_body_timeout 300s;
limit_req zone=my_limit burst=5 nodelay;

client_max_body_size 10m;
}

location / {
Expand All @@ -112,11 +107,8 @@ http {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
client_body_timeout 300s;
limit_req zone=my_limit burst=5 nodelay;
client_max_body_size 10m;


proxy_no_cache 1;
proxy_cache_bypass 1;
}
Expand All @@ -128,8 +120,5 @@ http {
text/css 1d;
application/javascript 1d;
~image/ 7d;
~image/webp 7d;
~image/jpg 7d;
~image/jpeg 7d;
}
}

0 comments on commit 27a0ae3

Please sign in to comment.