This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
45 lines (44 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
worker_processes 1;
events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nodelay on;
keepalive_timeout 60;
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name nsas;
root /usr/share/nginx/front/dist;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location /nsas-api {
proxy_pass http://139.159.243.90:800;
rewrite ^/nsas-api/(.*) /$1 break;
}
location / {
try_files $uri $uri/ /front/dist/index.html /dist/index.html @fallback;
index index.html index.htm;
gzip_static on;
expires max;
add_header Cache-Control public;
add_header 'Access-Control-Allow-Origin' '*';
# 添加其他必要的头部信息,例如请求方法,允许的头部,以及是否允许发送凭证(如Cookie等)
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Allow-Credentials' 'true';
if ($request_filename ~* ^.*?\.(eot)|(ttf)|(woff)|(svg)|(otf)$) {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Allow-Credentials' 'true';
}
}
location @fallback {
rewrite ^(.*)$ /index.html break;
}
}
}