-
Notifications
You must be signed in to change notification settings - Fork 1
/
nginx.conf
76 lines (55 loc) · 2.26 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
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
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
# include /etc/nginx/conf.d/*.conf;
# 开启gzip
gzip on;
# 启用gzip压缩的最小文件,小于设置值的文件将不会压缩
gzip_min_length 1k;
# gzip 压缩级别,1-10,数字越大压缩的越好,也越占用CPU时间。一般设置1和2
gzip_comp_level 1;
# 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
# 是否在http header中添加Vary: Accept-Encoding,建议开启
gzip_vary on;
# 禁用IE 8 gzip
gzip_disable "MSIE [1-8]\.";
# 设置缓存路径并且使用一块最大100M的共享内存,用于硬盘上的文件索引,包括文件名和请求次数,每个文件在1天内若不活跃(无请求)则从硬盘上淘汰,硬盘缓存最大10G,满了则根据LRU算法自动清除缓存。
proxy_cache_path /usr/share/nginx/cache/ levels=1:2 keys_zone=imgcache:100m inactive=1d max_size=10g;
# add_header Cache-Control "public, max-age=31536000";
add_header Localtion-Domain "tenxcloud";
fastcgi_intercept_errors on;
server {
listen 80;
server_name_in_redirect off;
# location ~.*\.(jpg|jpeg|gif|png|svg)$ {
# expires 30d;
# }
# location ~.*\.(pdf|css|html|js|swf)$ {
# expires 1d;
# }
root /dist/vsion.liusisi;
error_page 404 /dist/vsion.liusisi/404.html;
rewrite ^/(.*)\.html /$1;
location /vsion.liusisi {
# rewrite ^(/.*)\.html(\?.*)?$ $1$2;
rewrite ^/(.*)/$ /$1;
try_files $uri/index.html $uri.html $uri/ $uri =404 redirect;
}
}
}