|
| 1 | +worker_processes 1; |
| 2 | + |
| 3 | +events { |
| 4 | + worker_connections 1024; |
| 5 | + multi_accept on; |
| 6 | + accept_mutex off; |
| 7 | + use epoll; |
| 8 | +} |
| 9 | + |
| 10 | +http { |
| 11 | + access_log off; |
| 12 | + log_format pokeapilogformat |
| 13 | + '$remote_addr ' |
| 14 | + '"$request" $status cs:$upstream_cache_status s:$bytes_sent ' |
| 15 | + 'r:"$http_referer"'; |
| 16 | + error_log /dev/stdout warn; |
| 17 | + include mime.types; |
| 18 | + default_type application/octet-stream; |
| 19 | + |
| 20 | + server_tokens off; |
| 21 | + |
| 22 | + add_header X-XSS-Protection "1; mode=block"; |
| 23 | + |
| 24 | + client_body_buffer_size 10K; |
| 25 | + client_header_buffer_size 1k; |
| 26 | + client_max_body_size 8m; |
| 27 | + |
| 28 | + sendfile on; |
| 29 | + tcp_nopush on; |
| 30 | + tcp_nodelay on; |
| 31 | + |
| 32 | + keepalive_timeout 5; |
| 33 | + |
| 34 | + gzip on; |
| 35 | + gzip_disable "msi6"; |
| 36 | + gzip_vary on; |
| 37 | + gzip_proxied any; |
| 38 | + gzip_comp_level 4; |
| 39 | + gzip_buffers 16 8k; |
| 40 | + gzip_http_version 1.1; |
| 41 | + gzip_min_length 256; |
| 42 | + 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; |
| 43 | + |
| 44 | + resolver 127.0.0.11 valid=10s; |
| 45 | + |
| 46 | + geo $limit { |
| 47 | + default 1; |
| 48 | + 10.0.0.0/8 0; |
| 49 | + 192.168.0.0/24 0; |
| 50 | + } |
| 51 | + |
| 52 | + map $http_user_agent $exclude_ua { |
| 53 | + "~*monitoring*" 0; |
| 54 | + default 1; |
| 55 | + } |
| 56 | + |
| 57 | + map $request_method $only_post { |
| 58 | + default 0; |
| 59 | + POST $exclude_ua; |
| 60 | + } |
| 61 | + |
| 62 | + map $limit $limit_key { |
| 63 | + 0 ""; |
| 64 | + 1 $binary_remote_addr; |
| 65 | + } |
| 66 | + |
| 67 | + limit_req_zone $limit_key zone=graphqlDefaultLimit:50m rate=1r/m; |
| 68 | + limit_conn_zone $binary_remote_addr zone=addr:20m; |
| 69 | + proxy_cache_path /tmp/cache levels=1:2 keys_zone=small:40m inactive=10d max_size=2g use_temp_path=off; |
| 70 | + |
| 71 | + upstream gqle { |
| 72 | + zone upstream_dynamic 64k; |
| 73 | + server graphql-engine:8080 resolve; |
| 74 | + } |
| 75 | + |
| 76 | + server { |
| 77 | + listen 80 deferred; |
| 78 | + server_name _; |
| 79 | + root /code; |
| 80 | + |
| 81 | + include /ssl/ssl.conf*; |
| 82 | + |
| 83 | + client_body_timeout 5s; |
| 84 | + client_header_timeout 5s; |
| 85 | + limit_conn addr 10; |
| 86 | + |
| 87 | + # Admin console |
| 88 | + location /graphql/admin/ { |
| 89 | + expires 1m; |
| 90 | + add_header Cache-Control "public"; |
| 91 | + add_header Pragma public; |
| 92 | + proxy_http_version 1.1; |
| 93 | + proxy_set_header Upgrade $http_upgrade; |
| 94 | + proxy_set_header Connection "upgrade"; |
| 95 | + proxy_set_header X-Real-IP $remote_addr; |
| 96 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 97 | + proxy_set_header Host $http_host; |
| 98 | + proxy_redirect off; |
| 99 | + set $upstream_graphql graphql-engine; |
| 100 | + proxy_pass http://gqle/; |
| 101 | + } |
| 102 | + |
| 103 | + location /graphql/console { |
| 104 | + proxy_http_version 1.1; |
| 105 | + proxy_set_header Upgrade $http_upgrade; |
| 106 | + proxy_set_header Connection "upgrade"; |
| 107 | + proxy_set_header X-Real-IP $remote_addr; |
| 108 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 109 | + proxy_set_header Host $http_host; |
| 110 | + set $upstream_graphiql graphiql; |
| 111 | + proxy_pass http://$upstream_graphiql:80/; |
| 112 | + } |
| 113 | + |
| 114 | + location /graphql/v1beta { |
| 115 | + access_log /dev/stdout pokeapilogformat if=$only_post; |
| 116 | + include /ssl/cache.conf*; |
| 117 | + limit_req zone=graphqlDefaultLimit burst=200 nodelay; |
| 118 | + limit_req_status 429; |
| 119 | + expires 30m; |
| 120 | + add_header Cache-Control "public"; |
| 121 | + add_header Pragma public; |
| 122 | + proxy_hide_header Access-Control-Allow-Origin; |
| 123 | + add_header Access-Control-Allow-Origin *; |
| 124 | + proxy_http_version 1.1; |
| 125 | + proxy_set_header Upgrade $http_upgrade; |
| 126 | + proxy_set_header Connection "upgrade"; |
| 127 | + proxy_set_header X-Real-IP $remote_addr; |
| 128 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 129 | + proxy_set_header Host $http_host; |
| 130 | + proxy_redirect off; |
| 131 | + set $upstream_graphql graphql-engine; |
| 132 | + proxy_pass http://$upstream_graphql:8080/v1/graphql; |
| 133 | + } |
| 134 | + |
| 135 | + location /api/ { |
| 136 | + expires 1m; |
| 137 | + add_header Cache-Control "public"; |
| 138 | + add_header Pragma public; |
| 139 | + proxy_set_header X-Real-IP $remote_addr; |
| 140 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 141 | + proxy_set_header Host $http_host; |
| 142 | + proxy_redirect off; |
| 143 | + set $upstream app; |
| 144 | + proxy_pass http://$upstream:80; |
| 145 | + } |
| 146 | + |
| 147 | + location / { |
| 148 | + return 404; |
| 149 | + } |
| 150 | + } |
| 151 | +} |
0 commit comments