-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.hanyi.conf
93 lines (73 loc) · 2.46 KB
/
nginx.hanyi.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
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
listen 443 ssl;
server_name xxx.xxx.com;
ssl_certificate F:\git\ssl\xxx.pem;
ssl_certificate_key F:\git\ssl\xxx.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
autoindex on;
gzip on;
gzip_static on;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php application/javascript application/json;
gzip_proxied expired;
gzip_vary on;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
location /test {
root F:\git\test-cjm\dist;
if ($request_filename ~ .*\.(htm|html)$)
{
add_header Cache-Control no-cache;
}
if ($request_filename ~ .*\.(css|js|gif|jpg|jpeg|png|svg|bmp|swf|ttf|woff|otf|ttc|pfa)$)
{
add_header expires 30d;
}
try_files $uri $uri/ @test_rewrite_url;
index index.html;
}
location @test_rewrite_url {
rewrite ^/(test)/(.+)$ /$1/index.html last;
}
}
# spa单页应用nginx验证可用配置
server {
listen 3000;
server_name localhost;
# demo是项目base路径
location /demo {
root D:\my\project\demo\dist; // 打包好的项目路径
try_files $uri $uri/ @test_rewrite_url; // spa单页应用跳转到index.html
index index.html;
}
# 其他路径全部重定向到demo/index.html,单页应用必备配置
location @test_rewrite_url {
rewrite ^/(demo)/(.+)$ /$1/index.html last;
}
}
}