# Nginx
# 安装
执行如焉命令安装Nginx源。
[root@localhost ~] rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Text
1
使用 yum 命令安装 Ngnix
[root@localhost ~] yum install nginx
Text
1
配置开机启动与启动
[root@localhost ~] systemctl enable nginx
[root@localhost ~] systemctl start nginx
Text
1
2
2
# 配置
# 常用 Nginx 命令
启动nginx
[root@localhost ~] nginx
Text
1
测试 Nginx 配置是否正确
[root@localhost ~] nginx -t
Text
1
重启 Nginx
[root@localhost ~] nginx -s reload
Text
1
# Nginx的默认路径
- Nginx配置路径:/etc/nginx/
- PID目录:/var/run/nginx.pid
- 错误日志:/var/log/nginx/error.log
- 默认访问日志:/var/log/nginx/access.log
- 默认站点目录:/usr/share/nginx/html
- ibms访问日志:/opt/logs/host.access.log
# Nginx 配置
ibms Nginx配置文件
server {
listen 9001;
server_name localhost;
client_max_body_size 1024m;
#charset koi8-r;
access_log /opt/logs/host.access.log; # main;
root /opt/nginx/ibms/dist; #vue项目的打包后的dist
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
}
location @router {
rewrite ^.*$ /index.html last;
}
location ^~ /admin/ {
proxy_pass http://192.168.20.236:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
rewrite ^/admin/(.+?)$ /$1 break;
}
location ^~ /api/ {
proxy_pass http://192.168.20.236:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;#nginx服务器与被代理的服务器建立连接的超时时间
proxy_send_timeout 3600;#nginx服务器想被代理服务器组发出read请求后,等待响应的超时间
proxy_read_timeout 3600;#nginx服务器想被代理服务器组发出write请求后,等待响应的超时间
rewrite ^/api/(.+?)$ /$1 break;
}
location ^~ /modelapi/ {
proxy_pass http://192.168.20.225:8082;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 1024m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 36000;#nginx服务器与被代理的服务器建立连接的超时时间
proxy_send_timeout 36000;#nginx服务器想被代理服务器组发出read请求后,等待响应的超时间
proxy_read_timeout 36000;#nginx服务器想被代理服务器组发出write请求后,等待响应的超时间
rewrite ^/modelapi/(.+?)$ /revit-algorithm/$1 break;
}
location ^~ /data-platform-3/ {
proxy_pass http://192.168.20.225:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
rewrite ^/data-platform-3/(.+?)$ /data-platform-3/$1 break;
}
location ^~ /business-space/ {
proxy_pass http://192.168.20.225:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
rewrite ^/business-space/(.+?)$ /business-space/$1 break;
}
location ^~ /pointconfig/ {
proxy_pass http://192.168.20.236:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
rewrite ^/pointconfig/(.+?)$ /pointconfig/$1 break;
}
location ^~ /venders/ {
proxy_pass http://192.168.20.225:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
rewrite ^/venders/(.+?)$ /venders/$1 break;
}
location ^~ /venders-dp/ {
proxy_pass http://192.168.20.225:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
rewrite ^/venders-dp/(.+?)$ /venders-dp/$1 break;
}
location ^~ /ScanBuilding/ {
proxy_pass http://192.168.20.236:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
rewrite ^/ScanBuilding/(.+?)$ /ScanBuilding/$1 break;
}
location ^~ /image-service/ {
proxy_pass http://192.168.20.225:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 1024m;
client_body_buffer_size 1m;
proxy_buffers 32 4k;
proxy_connect_timeout 36000;
proxy_send_timeout 36000;
proxy_read_timeout 36000;
rewrite ^/image-service/(.+?)$ /image-service/$1 break;
}
location ^~ /godhand/ {
proxy_pass http://192.168.20.225:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
rewrite ^/godhand/(.+?)$ /godhand/$1 break;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Text
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176