Skip to content

Commit 6375361

Browse files
committed
fix: ERR_SSL_PROTOCOL_ERROR when using IP host.
1 parent b093a15 commit 6375361

File tree

1 file changed

+49
-16
lines changed

1 file changed

+49
-16
lines changed

nginx.conf

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,61 @@
1-
events { }
1+
events {
2+
}
23
http {
34

45
include mime.types;
56
sendfile on;
67

78
server {
8-
listen 24900;
9-
listen [::]:24900;
10-
server_name localhost;
9+
listen 24900 ssl;
10+
listen [::]:24900 ssl;
11+
server_name localhost;
1112

12-
#error_page 404 /404.html;
13-
root /usr/share/nginx/html;
13+
#error_page 404 /404.html;
14+
root /usr/share/nginx/html;
1415

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;
1919

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;
2547
}
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+
}
2659
}
2760

28-
}
61+
}

0 commit comments

Comments
 (0)