-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnginx.template.conf
116 lines (90 loc) · 3.01 KB
/
nginx.template.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
load_module modules/ngx_http_js_module.so;
user msaber;
worker_processes auto;
worker_cpu_affinity auto;
error_log /app/config/nginx/log/error.log warn;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# 设置缓存路径和缓存区大小
proxy_cache_path /tmp levels=1:2 keys_zone=my_cache:10m max_size=100m inactive=60m use_temp_path=off;
sendfile on;
keepalive_timeout 3600;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log /app/config/nginx/log/access.log main;
#默认关闭访问日志
access_log off;
server {
listen ${MS_PORT};
server_name _; # serve all hostnames
server_tokens off; # disable header "Server nginx"
# gzip compression
gzip on;
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
application/javascript
application/json
application/rss+xml
application/x-javascript
application/xml
image/svg+xml
text/css
text/javascript
text/js
text/plain
text/xml;
location / {
# 主目录
expires off;
add_header Cache-Control "no-cache, no-store, must-revalidate";
root /app/front;
try_files $uri $uri/ /index.html =404;
index index.html;
}
location ~* \.(js|css|ico|svg)$ {
# 缓存根目录下的 JS、CSS、ICO 和 SVG 文件
expires 30d;
add_header Cache-Control "public";
root /app/front;
}
location /assets {
# 静态资源
expires 30d;
add_header Cache-Control "public";
root /app/front;
}
location /static {
# 静态资源
expires 30d;
add_header Cache-Control "public";
root /app/config/data;
}
location /api {
# 后端API
proxy_pass http://backend_api;
proxy_http_version 1.1;
proxy_buffering off;
proxy_cache off;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
upstream backend_api {
# 后端API的地址和端口
server 127.0.0.1:22698;
# 可以添加更多后端服务器作为负载均衡
}
#加载自定义配置
include /app/config/nginx/vhost/*.conf;
}