-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
45 lines (37 loc) · 1.18 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
events {
worker_connections 1024;
}
http {
upstream api {
server api:8000;
}
server {
listen 80;
server_name localhost;
# CORS settings
set $cors_credentials 'true';
set $cors_content_type '';
set $cors_content_length '';
if ($http_origin ~ '.+') {
set $cors_credentials 'true';
}
if ($request_method = OPTIONS) {
set $cors_content_type 'text/plain';
set $cors_content_length '0';
}
# CORS headers
add_header Access-Control-Allow-Origin $http_origin always;
add_header Access-Control-Allow-Credentials $cors_credentials always;
add_header Access-Control-Allow-Methods "GET, POST" always;
add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Signature,Account-Id" always;
# Handle preflight requests
if ($request_method = OPTIONS) {
return 204;
}
location / {
proxy_pass http://api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}