2016-08-12 13:49:57 +00:00
|
|
|
worker_processes 4; # 80$ droplet, so 4 core enabled
|
2016-07-07 12:23:59 +00:00
|
|
|
|
|
|
|
events {
|
2016-08-12 13:49:57 +00:00
|
|
|
worker_connections 8096; # accepted incoming connections*2
|
|
|
|
multi_accept on; # accept each connection as soon as you can
|
2016-07-07 12:23:59 +00:00
|
|
|
accept_mutex off;
|
|
|
|
use epoll;
|
|
|
|
}
|
|
|
|
|
|
|
|
http {
|
|
|
|
include mime.types;
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
2016-08-12 13:49:57 +00:00
|
|
|
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
|
|
|
|
|
2016-07-07 12:23:59 +00:00
|
|
|
sendfile on;
|
|
|
|
tcp_nopush on;
|
|
|
|
tcp_nodelay on;
|
|
|
|
|
|
|
|
keepalive_timeout 5;
|
2016-08-12 13:49:57 +00:00
|
|
|
|
|
|
|
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";
|
2016-07-07 12:23:59 +00:00
|
|
|
|
|
|
|
upstream pokeapi_upstream {
|
|
|
|
# 'app' is the Django container name in Docker
|
|
|
|
# DO NOT EDIT IT ALONE or it'll break docker-compose
|
|
|
|
server app:8000 fail_timeout=0;
|
|
|
|
}
|
|
|
|
|
2021-03-19 18:09:59 +00:00
|
|
|
upstream graphql_upstream {
|
|
|
|
server graphql-engine:8080 fail_timeout=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
geo $limit {
|
|
|
|
default 1;
|
|
|
|
10.0.0.0/8 0;
|
|
|
|
192.168.0.0/24 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
map $limit $limit_key {
|
|
|
|
0 "";
|
|
|
|
1 $binary_remote_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
limit_req_zone $limit_key zone=graphqlDefaultLimit:50m rate=1r/m;
|
|
|
|
|
2016-07-07 12:23:59 +00:00
|
|
|
server {
|
|
|
|
listen 80 deferred;
|
|
|
|
server_name _;
|
|
|
|
|
2021-03-22 18:31:59 +00:00
|
|
|
include /ssl/ssl.conf*;
|
|
|
|
|
2016-07-07 12:23:59 +00:00
|
|
|
client_body_timeout 5s;
|
|
|
|
client_header_timeout 5s;
|
|
|
|
|
|
|
|
root /code;
|
|
|
|
|
2021-03-19 18:09:59 +00:00
|
|
|
|
|
|
|
# Admin console
|
|
|
|
location /graphql/admin/ {
|
|
|
|
expires 1m; # client-side caching, one minute for each API resource
|
|
|
|
add_header Cache-Control "public";
|
|
|
|
add_header Pragma public;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
|
|
|
|
proxy_redirect off;
|
|
|
|
|
|
|
|
proxy_pass http://graphql_upstream/;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /graphql/console {
|
|
|
|
alias /public-console/;
|
|
|
|
index index.html;
|
|
|
|
try_files $uri $uri/ /index.html =405;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /graphql/v1beta {
|
|
|
|
limit_req zone=graphqlDefaultLimit burst=100 nodelay;
|
|
|
|
limit_req_status 429;
|
|
|
|
expires 1m; # client-side caching, one minute for each API resource
|
|
|
|
add_header Cache-Control "public";
|
|
|
|
add_header Pragma public;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
|
|
|
|
proxy_redirect off;
|
|
|
|
|
|
|
|
proxy_pass http://graphql_upstream/v1/graphql;
|
|
|
|
}
|
|
|
|
|
2016-07-07 12:23:59 +00:00
|
|
|
location /media/ {
|
|
|
|
root /code;
|
|
|
|
autoindex off;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /static/ {
|
|
|
|
alias /code/assets/;
|
|
|
|
autoindex off;
|
|
|
|
}
|
2016-08-12 13:49:57 +00:00
|
|
|
|
2016-07-07 12:23:59 +00:00
|
|
|
location /api/ {
|
2016-08-12 13:49:57 +00:00
|
|
|
expires 1m; # client-side caching, one minute for each API resource
|
|
|
|
add_header Cache-Control "public";
|
|
|
|
add_header Pragma public;
|
|
|
|
|
2016-07-07 12:23:59 +00:00
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
|
|
|
|
proxy_redirect off;
|
|
|
|
|
|
|
|
proxy_pass http://pokeapi_upstream;
|
|
|
|
}
|
|
|
|
|
2021-03-19 18:09:59 +00:00
|
|
|
# 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;
|
|
|
|
# }
|
|
|
|
|
2016-07-07 12:23:59 +00:00
|
|
|
location / {
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
|
|
|
|
proxy_redirect off;
|
|
|
|
|
|
|
|
proxy_pass http://pokeapi_upstream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|