1- worker_processes 2 ;
1+ worker_processes 1 ;
22
33events {
4- worker_connections 4096 ;
4+ worker_connections 1024 ;
55 multi_accept on; # accept each connection as soon as you can
66 accept_mutex off;
77 use epoll;
@@ -24,21 +24,18 @@ http {
2424 tcp_nodelay on;
2525
2626 keepalive_timeout 5;
27-
27+
2828 gzip on;
2929 gzip_disable "msi6" ;
3030 gzip_vary on;
3131 gzip_proxied any;
32- gzip_comp_level 6 ;
32+ gzip_comp_level 4 ;
3333 gzip_buffers 16 8k ;
3434 gzip_http_version 1.1;
3535 gzip_min_length 256 ;
3636 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;
3737
38- upstream pokeapi_upstream {
39- # 'app' is the Django container name in Docker
40- server app:80 fail_timeout=0;
41- }
38+ resolver 127.0.0.11 valid=30s ;
4239
4340 upstream graphql_upstream {
4441 server graphql-engine:8080 fail_timeout=0;
5754
5855 limit_req_zone $limit_key zone =graphqlDefaultLimit:50m rate=1r /m;
5956 limit_conn_zone $binary_remote_addr zone =addr:20m ;
57+ proxy_cache_path /tmp/cache levels=1:2 keys_zone=small:40m inactive=10d max_size=2g use_temp_path=off;
6058
6159 server {
6260 listen 80 deferred;
@@ -91,11 +89,18 @@ http {
9189 }
9290
9391 location /graphql/v1beta {
92+ # proxy_cache small;
93+ # proxy_cache_valid 200 10d;
94+ # proxy_cache_valid any 0;
95+ # proxy_cache_methods POST;
96+ # proxy_cache_key "$request_method$request_uri$request_body";
9497 limit_req zone =graphqlDefaultLimit burst=100 nodelay;
9598 limit_req_status 429 ;
96- expires 1m ; # client-side caching, one minute for each API resource
99+ expires 30m ; # client-side caching, one minute for each API resource
97100 add_header Cache-Control "public" ;
98101 add_header Pragma public;
102+ # add_header X-Proxy-Cache $upstream_cache_status;
103+ # add_header X-Cache-Date $upstream_http_date;
99104 proxy_http_version 1.1;
100105 proxy_set_header Upgrade $http_upgrade ;
101106 proxy_set_header Connection "upgrade" ;
@@ -105,7 +110,7 @@ http {
105110 proxy_redirect off;
106111 proxy_pass http ://graphql_upstream/v1/graphql;
107112 }
108-
113+
109114 location /api/ {
110115 expires 1m ; # client-side caching, one minute for each API resource
111116 add_header Cache-Control "public" ;
@@ -114,15 +119,12 @@ http {
114119 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
115120 proxy_set_header Host $http_host ;
116121 proxy_redirect off;
117- proxy_pass http ://pokeapi_upstream;
122+ set $upstream app;
123+ proxy_pass http ://$upstream :80 ;
118124 }
119125
120126 location / {
121- proxy_set_header X-Real-IP $remote_addr ;
122- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
123- proxy_set_header Host $http_host ;
124- proxy_redirect off;
125- proxy_pass http ://pokeapi_upstream;
127+ return 404 ;
126128 }
127129 }
128130}
0 commit comments