nginx
nginx 安装
sudo apt-get install nginx
1
nginx 命令
sudo service nginx {start|stop|restart|reload|force-reload|status|configtest|rotate|upgrade}
1
默认 config 路径
vim /etc/nginx/nginx.conf
1
我的 config 路径
vim /etc/nginx/conf.d/nginx.default.conf
1
nginx 重启
service nginx restart
nginx -s restart
nginx -s reload
1
2
3
4
5
2
3
4
5
nginx 查看配置文件
nginx -t
1
nginx 配置1
# 查看是否以守护进程的方式运行Nginx 默认是on
daemon off;
# Nginx worker进程个数,根据机器配置有多少cpu配置多少进程即可
worker_processes 8;
error_log /home/work/nginx/logs/error.log notice;
events {
use epoll;
# 每个work进程最大连接数
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
# 输出日志格式
log_format main '$http_clientip - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$no_bduss_http_cookie" "$http_user_agent" '
'rt=$request_time logid=$http_log_id bfe_logid=$http_bfe_logid x_bd_logid=$http_x_bd_logid '
'$remote_addr $server_addr $upstream_addr $host '
'"$http_x_forwarded_for" ps appEngine - $msec';
server_names_hash_bucket_size 128;
client_header_buffer_size 4k;
large_client_header_buffers 4 32k;
client_max_body_size 4m;
client_body_buffer_size 512k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 0;
chunked_transfer_encoding off;
underscores_in_headers on;
gzip off;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary off;
proxy_connect_timeout 15s;
proxy_read_timeout 24s;
proxy_send_timeout 10s;
proxy_buffer_size 64k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_set_header Host $http_host;
proxy_set_header Remote-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_intercept_errors on;
uninitialized_variable_warn off;
limit_req_zone $remote_user zone=req_one:10m rate=1000r/s;
limit_conn_zone $remote_user zone=req_two:10m;
server {
listen 80;
server_name_in_redirect off;
port_in_redirect off;
absolute_redirect off;
#server_name localhost;
# 访问日志输出目录
access_log /home/work/nginx/logs/access.log main;
#charset koi8-r;
#access_log logs/host.access.log main;
root /home/work/podium;
location ^~ /podium/assets {
alias /home/work/podium/assets;
}
# root 配置为模板文件存放路径
location ^~ /podium {
root /home/work/podium;
try_files $uri $uri/ /index-stable.html;
#rewrite /podium/(.*) /index-stable.html?$1 break;
index index-stable.html index-stable.htm;
}
set $no_bduss_http_cookie "";
if ($http_cookie ~* "(.*)BDUSS=(.+?)(?:;|$)(.*)") {
set $no_bduss_http_cookie $1$3;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
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
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
nginx 配置2
server {
listen 80;
server_name localhost;
charset utf-8;
access_log off;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location /api/basic {
proxy_pass http://gatewaydev-jiaopei.testyf.ak/basic;
}
location /api/org {
proxy_pass http://gatewaydev-jiaopei.testyf.ak/organization;
}
location /api/portal {
proxy_pass http://gatewaydev-jiaopei.testyf.ak/xiaoben-portalweb;
}
location /ueeditor {
proxy_pass http://pc-home-dev-jiaopei.testyf.ak/ueeditor;
}
location /aliyun/token {
proxy_pass http://pc-home-dev-jiaopei.testyf.ak/aliyun/token;
}
}
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
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
nginx配置 服务器上
server {
listen 80 default_server;
listen [::]:80 default_server;
root /home/ubuntu/vue-press/dist;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16