pokeapi/Resources/nginx/nginx.conf

144 lines
4.1 KiB
Nginx Configuration File
Raw Normal View History

2021-08-30 15:22:03 +00:00
worker_processes 1;
events {
2021-08-30 15:22:03 +00:00
worker_connections 1024;
2024-02-09 18:34:47 +00:00
multi_accept on;
accept_mutex off;
use epoll;
}
http {
2024-02-09 18:34:47 +00:00
access_log off;
log_format pokeapilogformat
'$remote_addr '
'"$request" $status cs:$upstream_cache_status s:$bytes_sent '
'r:"$http_referer"';
error_log /dev/stdout warn;
include mime.types;
default_type application/octet-stream;
2024-02-09 18:34:47 +00:00
server_tokens off;
2024-02-09 18:34:47 +00:00
add_header X-XSS-Protection "1; mode=block";
2024-02-09 18:34:47 +00:00
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
2024-02-09 18:34:47 +00:00
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 5;
2021-08-30 16:24:56 +00:00
2021-03-23 18:11:33 +00:00
gzip on;
gzip_disable "msi6";
2021-03-23 18:11:33 +00:00
gzip_vary on;
gzip_proxied any;
2021-08-30 15:22:03 +00:00
gzip_comp_level 4;
2021-03-23 18:11:33 +00:00
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types application/atom+xml application/geo+json application/javascript application/x-javascript application/json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/xhtml+xml application/xml font/eot font/otf font/ttf image/svg+xml text/css text/javascript text/plain text/xml;
2021-08-30 16:24:56 +00:00
resolver 127.0.0.11 valid=30s;
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;
}
2024-02-09 18:34:47 +00:00
map $http_user_agent $exclude_ua {
"~*monitoring*" 0;
default 1;
}
map $request_method $only_post {
default 0;
POST $exclude_ua;
}
2021-03-19 18:09:59 +00:00
map $limit $limit_key {
0 "";
1 $binary_remote_addr;
}
limit_req_zone $limit_key zone=graphqlDefaultLimit:50m rate=1r/m;
2021-03-23 18:21:01 +00:00
limit_conn_zone $binary_remote_addr zone=addr:20m;
2021-08-30 15:22:03 +00:00
proxy_cache_path /tmp/cache levels=1:2 keys_zone=small:40m inactive=10d max_size=2g use_temp_path=off;
2021-03-19 18:09:59 +00:00
server {
listen 80 deferred;
server_name _;
2021-03-23 18:11:33 +00:00
root /code;
2021-03-22 18:31:59 +00:00
include /ssl/ssl.conf*;
client_body_timeout 5s;
client_header_timeout 5s;
2021-08-30 16:24:56 +00:00
limit_conn addr 10;
2021-03-19 18:09:59 +00:00
# Admin console
location /graphql/admin/ {
2024-02-09 18:34:47 +00:00
expires 1m;
2021-03-19 18:09:59 +00:00
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 {
2021-10-29 08:19:32 +00:00
alias /public-console;
2021-03-19 18:09:59 +00:00
index index.html;
try_files $uri $uri/ /index.html =405;
}
location /graphql/v1beta {
2024-02-09 18:34:47 +00:00
access_log /dev/stdout pokeapilogformat if=$only_post;
2024-01-09 19:48:28 +00:00
include /ssl/cache.conf*;
2021-03-19 18:09:59 +00:00
limit_req zone=graphqlDefaultLimit burst=100 nodelay;
limit_req_status 429;
2024-02-09 18:34:47 +00:00
expires 30m;
2021-03-19 18:09:59 +00:00
add_header Cache-Control "public";
add_header Pragma public;
2022-02-25 18:27:32 +00:00
proxy_hide_header Access-Control-Allow-Origin;
add_header Access-Control-Allow-Origin *;
2021-03-19 18:09:59 +00:00
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;
}
2021-08-30 16:24:56 +00:00
location /api/ {
2024-02-09 18:34:47 +00:00
expires 1m;
2021-08-30 16:24:56 +00:00
add_header Cache-Control "public";
add_header Pragma public;
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;
set $upstream app;
proxy_pass http://$upstream:80;
2021-08-30 16:24:56 +00:00
}
location / {
2021-08-30 15:22:03 +00:00
return 404;
}
}
}