1- worker_processes 4 ; # 80 $ droplet, so 4 core enabled
1+ worker_processes 2 ;
22
33events {
4- worker_connections 8096 ; # accepted incoming connections*2
4+ worker_connections 4096 ;
55 multi_accept on; # accept each connection as soon as you can
66 accept_mutex off;
77 use epoll;
@@ -17,24 +17,26 @@ http {
1717
1818 client_body_buffer_size 10K ; # raise the threshold by which requests are written to HDD instead of RAM
1919 client_header_buffer_size 2k ;
20- client_max_body_size 8m ; # we dont accept requests larger that 8mb , probably you are DoSing us
20+ client_max_body_size 8m ; # we dont accept requests larger that 8mb
2121
2222 sendfile on;
2323 tcp_nopush on;
2424 tcp_nodelay on;
2525
2626 keepalive_timeout 5;
2727
28- gzip on; # enable zipping files
29- gzip_vary on;
30- gzip_min_length 5120 ; # enable it only for medium-big files ( slowbro size is 7000 )
31- gzip_proxied expired no-cache no-store private auth;
32- gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/json;
28+ gzip on;
3329 gzip_disable "msi6" ;
30+ gzip_vary on;
31+ gzip_proxied any;
32+ gzip_comp_level 6;
33+ gzip_buffers 16 8k ;
34+ gzip_http_version 1.1;
35+ gzip_min_length 256 ;
36+ 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;
3437
3538 upstream pokeapi_upstream {
3639 # 'app' is the Django container name in Docker
37- # DO NOT EDIT IT ALONE or it'll break docker-compose
3840 server app:8000 fail_timeout=0;
3941 }
4042
@@ -58,15 +60,13 @@ http {
5860 server {
5961 listen 80 deferred;
6062 server_name _;
63+ root /code;
6164
6265 include /ssl /ssl .conf*;
6366
6467 client_body_timeout 5s ;
6568 client_header_timeout 5s ;
6669
67- root /code;
68-
69-
7070 # Admin console
7171 location /graphql/admin/ {
7272 expires 1m ; # client-side caching, one minute for each API resource
7878 proxy_set_header X-Real-IP $remote_addr ;
7979 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
8080 proxy_set_header Host $http_host ;
81-
8281 proxy_redirect off;
83-
8482 proxy_pass http ://graphql_upstream/;
8583 }
8684
@@ -102,51 +100,26 @@ http {
102100 proxy_set_header X-Real-IP $remote_addr ;
103101 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
104102 proxy_set_header Host $http_host ;
105-
106103 proxy_redirect off;
107-
108104 proxy_pass http ://graphql_upstream/v1/graphql;
109105 }
110-
111- location /media/ {
112- root /code;
113- autoindex off;
114- }
115-
116- location /static/ {
117- alias /code/assets/;
118- autoindex off;
119- }
120106
121107 location /api/ {
122108 expires 1m ; # client-side caching, one minute for each API resource
123109 add_header Cache-Control "public" ;
124110 add_header Pragma public;
125-
126111 proxy_set_header X-Real-IP $remote_addr ;
127112 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
128113 proxy_set_header Host $http_host ;
129-
130114 proxy_redirect off;
131-
132115 proxy_pass http ://pokeapi_upstream;
133116 }
134117
135- # location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { # cache all these extensions for 5 days, disable logging
136- # access_log off;
137- # log_not_found off;
138- # expires 5d;
139- # add_header Cache-Control "public";
140- # add_header Pragma public;
141- # }
142-
143118 location / {
144119 proxy_set_header X-Real-IP $remote_addr ;
145120 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
146121 proxy_set_header Host $http_host ;
147-
148122 proxy_redirect off;
149-
150123 proxy_pass http ://pokeapi_upstream;
151124 }
152125 }
0 commit comments