-
Notifications
You must be signed in to change notification settings - Fork 3
/
nginx.example.conf
71 lines (63 loc) · 2.47 KB
/
nginx.example.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# MaCPepDB WebAPI handler for fast requests (e.g. amino acids, modifications, ...)
upstream fast_requests_handler {
server backend_1:3000;
}
# MaCPepDB WebAPI handler for slow requests (e.g. peptide search)
upstream slow_requests_handler {
least_conn;
server backend_2:3000 fail_timeout=30m max_fails=0;
server backend_3:3000 fail_timeout=30m max_fails=0;
}
server {
listen 8080;
server_name localhost;
# Adjust handling of client body
client_max_body_size 500M;
client_body_buffer_size 30M;
# Make files sending more efficient
sendfile on;
tcp_nopush on;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Expose-Headers Content-Type;
# Deliver fast requests
location ~ ^/api(/dashboard|/proteins/amino-acids|/documents) {
# Check if request is served by the correct request. Disable in production.
add_header Served-By "fast backend";
proxy_pass http://fast_requests_handler;
# Disable buffering of upstream responses.
proxy_buffering off;
# Set proxy headers for Flask
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Disable passing on to next upstreamserver
# proxy_next_upstream off;
# Adjust timeouts
proxy_connect_timeout 20s;
proxy_send_timeout 20s;
proxy_read_timeout 20s;
send_timeout 20s;
}
# Deliver slow requests content
location ~ ^/api {
# Check if request is served by the correct request. Disable in production.
add_header Served-By "slow backend";
proxy_pass http://slow_requests_handler;
# Disable buffering of upstream responses.
proxy_buffering off;
# Set proxy headers for Flask
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Disable passing on to next upstream server
# proxy_next_upstream off;
# Adjust timeouts
proxy_connect_timeout 30m;
proxy_send_timeout 30m;
proxy_read_timeout 30m;
send_timeout 30m;
}
}