1
- events { }
1
+ events {
2
+ }
2
3
http {
3
4
4
5
include mime.types;
5
6
sendfile on ;
6
7
7
8
server {
8
- listen 24900 ;
9
- listen [::]:24900;
10
- server_name localhost;
9
+ listen 24900 ssl ;
10
+ listen [::]:24900 ssl ;
11
+ server_name localhost;
11
12
12
- #error_page 404 /404.html;
13
- root /usr/share/nginx/html;
13
+ #error_page 404 /404.html;
14
+ root /usr/share/nginx/html;
14
15
15
- # direct all traffic to index.html for client-side SPA routing
16
- location / {
17
- try_files $uri $uri / /index.html;
18
- }
16
+ # direct all traffic to index.html for client-side SPA routing
17
+ location / {
18
+ try_files $uri $uri / /index.html;
19
19
20
- # redirect server error pages to the static page /50x.html
21
- #
22
- error_page 500 502 503 504 /50x.html;
23
- location = /50x.html {
24
- root /usr/share/nginx/html;
20
+ # enable CORS
21
+ if ($request_method = 'OPTIONS' ) {
22
+ add_header 'Access-Control-Allow-Origin' '*' ;
23
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' ;
24
+ #
25
+ # Custom headers and headers various browsers *should* be OK with but aren't
26
+ #
27
+ add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' ;
28
+ #
29
+ # Tell client that this pre-flight info is valid for 20 days
30
+ #
31
+ add_header 'Access-Control-Max-Age' 1728000 ;
32
+ add_header 'Content-Type' 'text/plain; charset=utf-8' ;
33
+ add_header 'Content-Length' 0 ;
34
+ return 204 ;
35
+ }
36
+ if ($request_method = 'POST' ) {
37
+ add_header 'Access-Control-Allow-Origin' '*' always;
38
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
39
+ add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
40
+ add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
41
+ }
42
+ if ($request_method = 'GET' ) {
43
+ add_header 'Access-Control-Allow-Origin' '*' always;
44
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
45
+ add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
46
+ add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
25
47
}
48
+ }
49
+
50
+ # redirect https to http
51
+ error_page 497 301 http://$http_host$request_uri ;
52
+
53
+ # redirect server error pages to the static page /50x.html
54
+ #
55
+ error_page 500 502 503 504 /50x.html;
56
+ location = /50x.html {
57
+ root /usr/share/nginx/html;
58
+ }
26
59
}
27
60
28
- }
61
+ }
0 commit comments