-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
58 lines (48 loc) · 1.83 KB
/
nginx.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
worker_processes 1;
events { worker_connections 1024; }
http {
sendfile on;
upstream app_servers {
server opencodelab-app-server-1:3000;
server opencodelab-app-server-2:3000;
server opencodelab-app-server-3:3000;
server opencodelab-app-server-4:3000;
# Add more app-server instances here if needed
}
upstream polling_servers {
server opencodelab-polling-server-1:8080;
server opencodelab-polling-server-2:8080;
}
server {
listen 80;
# serve all locations here except /consumer
location /consumer {
if ($http_origin = "http://localhost:3000") {
add_header "Access-Control-Allow-Origin" "http://localhost:3000";
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
add_header "Access-Control-Allow-Credentials" "true";
}
proxy_pass http://polling_servers;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location / {
if ($http_origin = "http://localhost:3000") {
add_header "Access-Control-Allow-Origin" "http://localhost:3000";
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
add_header "Access-Control-Allow-Credentials" "true";
}
proxy_pass http://app_servers;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}