@@ -38,39 +38,39 @@ server {
3838
3939upstream search {
4040 ip_hash;
41- keepalive 32;
41+ keepalive {{ groups['search_api '] | length * 2 }}; # 2 connections per backend server.
4242
4343 {% for host in groups ['search_api' ] %}
4444 server {{ hostvars[host] ['vlan_ip'] | ipaddr('address') }} max_fails=3 fail_timeout=10s;
4545 {% endfor %}
4646}
4747
4848upstream metadata {
49- keepalive 32 ;
49+ keepalive {{ groups['search_api '] | length * 2 }} ;
5050
5151 {% for host in groups ['search_api' ] %}
5252 server {{ hostvars[host] ['vlan_ip'] | ipaddr('address') }} max_fails=3 fail_timeout=10s;
5353 {% endfor %}
5454}
5555
5656upstream nsfw {
57- keepalive 32 ;
57+ keepalive {{ groups['search_api '] | length * 2 }} ;
5858
5959 {% for host in groups ['nsfw_server' ] %}
6060 server {{ hostvars[host] ['vlan_ip'] | ipaddr('address') }} max_fails=3 fail_timeout=10;
6161 {% endfor %}
6262}
6363
6464upstream pinservice {
65- keepalive 32 ;
65+ keepalive {{ groups['search_api '] | length * 2 }} ;
6666
6767 {% for host in groups ['pinservice' ] %}
6868 server {{ hostvars[host] ['vlan_ip'] | ipaddr('address') }} max_fails=3 fail_timeout=10;
6969 {% endfor %}
7070}
7171
7272upstream nyats {
73- keepalive 32 ;
73+ keepalive {{ groups['search_api '] | length * 2 }} ;
7474
7575 {% for host in groups ['nyats' ] %}
7676 server {{ hostvars[host] ['vlan_ip'] | ipaddr('address') }} max_fails=0 fail_timeout=120s;
@@ -90,15 +90,18 @@ server {
9090 return 301 https://app.swaggerhub.com/apis-docs/ipfs-search/ipfs-search;
9191 }
9292
93- location /v1/search {
94- proxy_pass http://search/v1/search;
93+ # Required for backend keepalive
94+ proxy_http_version 1.1;
95+ proxy_set_header Connection "";
96+
97+ # Pass on remote address
98+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
9599
96- # Required for backend keepalive
97- proxy_http_version 1.1;
98- proxy_set_header Connection "";
100+ proxy_hide_header Access-Control-Allow-Origin;
101+ add_header Access-Control-Allow-Origin '*' always;
99102
100- # Pass on remote address
101- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
103+ location /v1/search {
104+ proxy_pass http://search/v1/search ;
102105
103106 proxy_cache search_cache;
104107 proxy_cache_use_stale updating;
@@ -112,37 +115,17 @@ server {
112115 expires 15m;
113116
114117 add_header X-Cache-Status $upstream_cache_status always;
115-
116- proxy_hide_header Access-Control-Allow-Origin;
117- add_header Access-Control-Allow-Origin '*' always;
118118 }
119119
120120 location /v1/queue-pinservice {
121121 proxy_pass http://pinservice/v1/queue-pinservice;
122122
123- # Required for backend keepalive
124- proxy_http_version 1.1;
125- proxy_set_header Connection "";
126-
127- # Pass on remote address
128- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
129-
130- proxy_read_timeout 5s;
131-
132- proxy_hide_header Access-Control-Allow-Origin;
133- add_header Access-Control-Allow-Origin '*' always;
123+ proxy_read_timeout 1s;
134124 }
135125
136126 location /v1/metadata {
137127 proxy_pass http://metadata/v1/metadata;
138128
139- # Required for backend keepalive
140- proxy_http_version 1.1;
141- proxy_set_header Connection "";
142-
143- # Pass on remote address
144- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
145-
146129 proxy_cache metadata_cache;
147130 proxy_cache_use_stale updating;
148131 proxy_cache_lock on;
@@ -155,21 +138,11 @@ server {
155138 expires 1y;
156139
157140 add_header X-Cache-Status $upstream_cache_status always;
158-
159- proxy_hide_header Access-Control-Allow-Origin;
160- add_header Access-Control-Allow-Origin '*' always;
161141 }
162142
163143 location /v1/nsfw {
164144 proxy_pass http://nsfw/v1/nsfw;
165145
166- # Required for backend keepalive
167- proxy_http_version 1.1;
168- proxy_set_header Connection "";
169-
170- # Pass on remote address
171- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
172-
173146 proxy_cache nsfw_cache;
174147 proxy_cache_use_stale updating;
175148 proxy_cache_lock on;
@@ -182,21 +155,11 @@ server {
182155 expires 1y;
183156
184157 add_header X-Cache-Status $upstream_cache_status always;
185-
186- proxy_hide_header Access-Control-Allow-Origin;
187- add_header Access-Control-Allow-Origin '*' always;
188158 }
189159
190160 location /v1/thumbnail {
191161 proxy_pass http://nyats/v1/thumbnail;
192162
193- # Required for backend keepalive
194- proxy_http_version 1.1;
195- proxy_set_header Connection "";
196-
197- # Pass on remote address
198- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
199-
200163 proxy_cache thumbnail_cache;
201164 proxy_cache_use_stale updating;
202165 proxy_cache_lock on;
@@ -209,13 +172,11 @@ server {
209172 expires 1y;
210173
211174 add_header X-Cache-Status $upstream_cache_status always;
212-
213- proxy_hide_header Access-Control-Allow-Origin;
214- add_header Access-Control-Allow-Origin '*' always;
215175 }
216176
217177 include {{ options_ssl_nginx }};
218178
219179 ssl_certificate /etc/letsencrypt/live/{{ certbot_name }}/fullchain.pem;
220180 ssl_certificate_key /etc/letsencrypt/live/{{ certbot_name }}/privkey.pem;
181+ ssl_trusted_certificate /etc/letsencrypt/live/{{ certbot_name }}/chain.pem;
221182}
0 commit comments