-
Notifications
You must be signed in to change notification settings - Fork 27
/
nginx.conf
145 lines (104 loc) · 3.31 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
user root;
worker_processes 2;
pid /root/nginx/logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_types text/plain text/css application/x-javascript application/javascript text/javascript application/json image/png;
server {
listen 80;
server_name app.nihaoshijie.com.cn localhost;
# 这里将非HTTPS的地址转向到HTTPS
rewrite ^(.*) https://$host$1 permanent;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name www.nihaoshijie.com.cn;
# 这里将非HTTPS的地址转向到HTTPS
# rewrite ^(.*) https://$host$1 permanent;
location / {
root html;
index index.html index.htm;
}
location /backend/ {
proxy_pass http://125.46.74.89:19629/;
}
}
# HTTPS server
# HTTPS 配置
server {
listen 443 ssl;
server_name www.nihaoshijie.com.cn;
# 配置证书路径
ssl_certificate /root/nginx/cert/wwwcert/2017439_www.nihaoshijie.com.cn.pem;
ssl_certificate_key /root/nginx/cert/wwwcert/2017439_www.nihaoshijie.com.cn.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 443 ssl;
server_name app.nihaoshijie.com.cn;
# 配置证书路径
ssl_certificate /root/nginx/cert/c.pem;
ssl_certificate_key /root/nginx/cert/c.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# 静态资源服务
location / {
# 给静态文件添加缓存
location ~ .*\.(js|css|png|jpeg)$ {
valid_referers *.nihaoshijie.com.cn;
if ($invalid_referer) {
return 404;
}
proxy_pass http://localhost:8080;
expires 3d;# 3天
}
proxy_pass http://localhost:8080;
}
location /index.html {
return 301 https://$server_name/;
}
# 后台服务
location ~/(cgi|socket) {
# 启用支持websocket连接
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://localhost:3000;
}
# ssr服务
location = /index_ssr {
proxy_pass http://localhost:8888;
}
# 给amdinMogo配一个路径
location /adminMogo {
proxy_pass http://localhost:1234/adminMogo;
}
}
}