mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-24 20:33:04 +00:00
Nginx 4cpu configuration (#240)
* Better performance teaks * moved declarations * cache api endpoint instead of .json files
This commit is contained in:
parent
7e78458e37
commit
a706bfbd9a
1 changed files with 30 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
|||
worker_processes 1;
|
||||
worker_processes 4; # 80$ droplet, so 4 core enabled
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
worker_connections 8096; # accepted incoming connections*2
|
||||
multi_accept on; # accept each connection as soon as you can
|
||||
accept_mutex off;
|
||||
use epoll;
|
||||
}
|
||||
|
@ -10,11 +11,26 @@ http {
|
|||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server_tokens off; # dont send unnecessary server info (like version)
|
||||
|
||||
add_header X-XSS-Protection "1; mode=block"; # prevent XSS
|
||||
|
||||
client_body_buffer_size 10K; # raise the threshold by which requests are written to HDD instead of RAM
|
||||
client_header_buffer_size 2k;
|
||||
client_max_body_size 8m; # we dont accept requests larger that 8mb, probably you are DoSing us
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
|
||||
keepalive_timeout 5;
|
||||
|
||||
gzip on; # enable zipping files
|
||||
gzip_vary on;
|
||||
gzip_min_length 5120; # enable it only for medium-big files (slowbro size is 7000)
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/json;
|
||||
gzip_disable "msi6";
|
||||
|
||||
upstream pokeapi_upstream {
|
||||
# 'app' is the Django container name in Docker
|
||||
|
@ -42,8 +58,20 @@ http {
|
|||
alias /code/assets/;
|
||||
autoindex off;
|
||||
}
|
||||
|
||||
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { # cache all these extensions for 5 days, disable logging
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
expires 5d;
|
||||
add_header Cache-Control "public";
|
||||
add_header Pragma public;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
expires 1m; # client-side caching, one minute for each API resource
|
||||
add_header Cache-Control "public";
|
||||
add_header Pragma public;
|
||||
|
||||
limit_req zone=api burst=10;
|
||||
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
|
Loading…
Reference in a new issue