TreeMind树图在线AI思维导图

Nignx思维导图

  收藏
  分享
会员免费下载30积分
会员免费使用30积分
U122866537 浏览量:52023-01-03 12:08:30
已被使用0次
查看详情Nignx思维导图

Nignx

树图思维导图提供 Nignx 在线思维导图免费制作,点击“编辑”按钮,可对 Nignx  进行在线思维导图编辑,本思维导图属于思维导图模板主题,文件编号是:2703fabada196d3d89015cc41ef08f10

思维导图大纲

Nignx思维导图模板大纲

使用

命令

-c

指定配置文件 默认路径--conf-path

-p

指定nginx安装目录

-g

临时指定一些全局配置项,以使新的配置项生效

nginx -g "pid /var/nginx/test.pid"

约束条件:

配置项不能与默认路径下nginx.conf 冲突,否则无法启动

以-g方式启动的nginx服务执行其他命令时,需要把 -g带上,否则可能出现配置项不匹配的情况

-t

测试配置文件是否有错误

-s

发送信号:stop, quit, reopen, reload

配置

<!--Note-->

user nobody;

worker

http { include mime.types; default

access_log access.log main; #access_log logs/yearudf/yearudf/month_udf/dayudf/dayudf/date_udf-access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; server_tokens off; #客户端连接参数配置 client_max_body_size 20m; #允许客户端请求的最大单文件字节数 client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数 client_header_buffer_size 256k; large_client_header_buffers 4 256k; keepalive_timeout 60s ; #长连接时长,让ssl设备与nginx连接时保持长连接 keepalive_requests 80920; #与后端服务连接参数配置 proxy_connect_timeout 60; #后端服务器连接超时时间(代理连接超时) proxy_send_timeout 60; #后端服务器数据回传时间(代理发送超时时间) proxy_read_timeout 65; #连接成功后,后端服务器响应时间(代理接收超时) proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小 proxy_buffers 4 256k; #proxy_buffers缓冲区,网页平均在256k以下的话,这样设置 proxy_busy_buffers_size 256k; #高负荷下缓冲大小(proxy_buffers*2) proxy_temp_file_write_size 256k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传 proxy_http_version 1.1; proxy_set_header Connection ""; proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; proxy_max_temp_file_size 128m; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header Cache-Control no-cache; proxy_set_header If-Modified-Since 0; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Cookie $http_cookie; #资源压缩配置 gzip on; #开启gzip压缩输出 gzip_min_length 1k; #最小压缩文件大小 gzip_buffers 4 16k; #压缩缓冲区 gzip_http_version 1.0; #压缩版本 gzip_comp_level 5; #压缩等级1-10,数字越大压缩率越高,建议4、5 gzip_types text/css application/javascript application/xml text/plain application/x-font-ttf ;#压缩的文件类型 gzip_proxied any; #服务限流(rate为后台服务tps/nginx服务数量) #limit_req_zone $binary_remote_addr zone=one:50m rate=3000r/s; server { listen 8080; server_name localhost; location /mbs-mbank { root html/; index index.html index.htm; } location ~/mbs-mbank/\S*\.(do|jsp)?$ { set $gateway "ares-mobile-gateway"; rewrite ^/mbs-mbank/(.*)$ /$gateway/$1 last; } location /ares-mobile-gateway { proxy_pass http://7.0.143.38:9080; #proxy_pass http://7.0.144.161:9080; } location /console { #proxy_pass http://7.0.143.38:9080; proxy_pass http://7.0.143.27:9080; } location /mbs-mbank/R { root html; autoindex on; } location /downloadFromPaperless { proxy_pass http://7.0.143.251:8080; } location ~/ares-behavior-analysis/\S*\.(do)?$ { proxy_pass http://7.0.143.129:8080; } location /portal{ root html; index index.html index.htm; } #配置文件下载 location /portal/download{ root html; #开启目录索引 autoindex on; } location /mbs-wbank{ root html/pwbank/; index index.html index.htm; } #跳转银联 #location /ares-channel-server{ # proxy_pass https://gateway.test.95516.com/; #} #转发到38服务器 location /mbs-resource { proxy_pass http://7.0.143.38:8080; } #转发到38服务器 location /mbs-resource-product { proxy_pass http://7.0.143.38:8080; } } server { listen 8002; server_name localhost; location /mbs-mbank { root html/; index index.html index.htm; } location ~/mbs-mbank/\S*\.(do|jsp)?$ { set $gateway "ares-mobile-gateway"; set $server "ares-channel-server"; rewrite ^/mbs-mbank/(.*)$ /$gateway/$1 last; } location /ares-mobile-gateway { #proxy_pass http://7.0.143.38:8080; #proxy_pass http://7.0.149.55:9080; proxy_pass http://7.0.144.161:9080; } } server { listen 9001; server_name localhost; location /mbs-mbank { root html/; index index.html index.htm; } location ~/mbs-mbank/\S*\.(do|jsp)?$ { set $gateway "ares-mobile-gateway"; rewrite ^/mbs-mbank/(.*)$ /$gateway/$1 last; } location /ares-mobile-gateway { proxy_pass http://7.0.143.38:9080; } location /ios3/profile.json { proxy_pass http://7.0.144.75:8088/ios3/profile.json; } location /android3/profile.json { proxy_pass http://7.0.144.75:8088/android3/profile.json; } location /mbs-resource { proxy_pass http://7.0.143.38:8080; } location /mbs-resource-product { proxy_pass http://7.0.143.38:8080; } } server { listen 8001; server_name localhost; location /mbs-mbank { root html/; index index.html index.htm; } location ~/mbs-mbank/\S*\.(do|jsp)?$ { set $gateway "ares-mobile-gateway"; set $server "ares-channel-server"; rewrite ^/mbs-mbank/(.*)$ /$gateway/$1 last; } location /ares-mobile-gateway { proxy_pass http://7.0.144.211:9080; #proxy_pass http://7.0.149.55:9080; } }

}

<!--/Note-->

调试经常和定位问题

daemon on | off;

是否守护进程方式运行

master_process on | off;

是否以master/woker方式工作

off; master进程自身处理请求

error_log  /path/file level;

日志设置

debug_points [stop | abort]

stop: 到代码调试点发出SIGSTOP信号以用于调试

abort: 产生一个coredump文件,可以使用gdb查看信息

debug_connection [IP | CIDR]

这个配置项实际上属于事件类配置 events { } 才有效

events { debug

worker

限制coredump核心转储文件的大小

working_directory path;

指定coredump文件生成目录

注意: 如果日志级别设定到debug, 必须configure 编译时加入--with-debug配置项

正常运行的配置项

env VAR|VAR=VALUE

定义环境变量

env TESTPATH=/TMP/;

include /path/file;

嵌入其他配置文件

include mime.types; include vhost/*.conf;

pid path/file;

pid文件的路径

默认: pid logs/nginx.pid;

user username [groupname];

nginx worker进程运行的用户及用户组

默认:user nobody nobody;

worker

一个worker进程可以打开的最大文件句柄数

worker

限制信号队列

设置每个用户发往nginx的信号队列的大小; 超过:信号量被丢掉

优化性能的配置项

worker_processes number

nginx worker 进程个数;最优个数为CPU内核个数;

worker

绑定nginx worker 进程到指定cpu内核;仅支持linux系统

ssl_engin device

SSL硬件加速;openssl engine -t

timer_resolution t

系统调用gettimeofday的执行频率

worker_priority nice

nginx worker 进程优先级设置

事件类配置项 events

accept_mutex [on| off]

是否打开accept锁;负载均衡锁

lock_file path/file;

lock文件的路径

默认:lock_file logs/nginx.loc

accept

使用accept锁后到真实建立连接之间的延迟时间

默认: accept

multi_accept [off | no]

批量建立新连接

use [kqueue | rtsig | epoll | /dev/poll | select | poll | eventport]

选择事件模型

worker_connection number;

每个worker的最大连接数

http {}

server {}

location [ = | ~ | ~* | ^~|@] /uri/ {}

= : 完全配置 ~ : 大小写敏感 ~*: 忽略大小写 ^~:前半部分匹配 @:内部请求重定向

# root path

## 以root方式设置资源路径

配置块: http,server,location,if location /download/ { root /opt/web/html/; } 如 请求URI是/download/index/test.html 则返回服务器上/opt/web/html//download/index/test.html文件的内容

# alias path

## 以alias方式设置资源路径

配置块:location location ~^/test/(\w+).(\w+)$ { alias /usr/local/nginx/$2/$1.$2;

} 丢去location后配置字符串; 请求 /test/nginx.conf时,nginx返回/usr/local/nginx/conf/nginx.conf文件内容

# index file ...

## 访问首页

配置块: http,server,location location / { index /index.html /index.php }

# error

## 根据HTTP返回码重定向页面

配置块: http,server,location,if

error

# recursive

## 是否允许递归使用error_page

配置块: http,server,location

# try_files path1 [path2] uri

## 按照顺序尝试获取有效 path,如全部无效返回uri

配置块: server,location try

listen address:port [ default | default

例如:

server_name name [...]

# 主机名称

server

# nginx 使用散列表来存储server name;设置每个散列桶占用内存大小

server

# 散列表的冲突率

默认:server

server

# 重定向主机名称处理

nginx.conf

<!--Note-->

user nobody;

worker

http { include mime.types; default

access_log access.log main; #access_log logs/yearudf/yearudf/month_udf/dayudf/dayudf/date_udf-access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; server_tokens off; #客户端连接参数配置 client_max_body_size 20m; #允许客户端请求的最大单文件字节数 client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数 client_header_buffer_size 256k; large_client_header_buffers 4 256k; keepalive_timeout 60s ; #长连接时长,让ssl设备与nginx连接时保持长连接 keepalive_requests 80920; #与后端服务连接参数配置 proxy_connect_timeout 60; #后端服务器连接超时时间(代理连接超时) proxy_send_timeout 60; #后端服务器数据回传时间(代理发送超时时间) proxy_read_timeout 65; #连接成功后,后端服务器响应时间(代理接收超时) proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小 proxy_buffers 4 256k; #proxy_buffers缓冲区,网页平均在256k以下的话,这样设置 proxy_busy_buffers_size 256k; #高负荷下缓冲大小(proxy_buffers*2) proxy_temp_file_write_size 256k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传 proxy_http_version 1.1; proxy_set_header Connection ""; proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; proxy_max_temp_file_size 128m; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header Cache-Control no-cache; proxy_set_header If-Modified-Since 0; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Cookie $http_cookie; #资源压缩配置 gzip on; #开启gzip压缩输出 gzip_min_length 1k; #最小压缩文件大小 gzip_buffers 4 16k; #压缩缓冲区 gzip_http_version 1.0; #压缩版本 gzip_comp_level 5; #压缩等级1-10,数字越大压缩率越高,建议4、5 gzip_types text/css application/javascript application/xml text/plain application/x-font-ttf ;#压缩的文件类型 gzip_proxied any; #服务限流(rate为后台服务tps/nginx服务数量) #limit_req_zone $binary_remote_addr zone=one:50m rate=3000r/s; server { listen 8080; server_name localhost; location /mbs-mbank { root html/; index index.html index.htm; } location ~/mbs-mbank/\S*\.(do|jsp)?$ { set $gateway "ares-mobile-gateway"; rewrite ^/mbs-mbank/(.*)$ /$gateway/$1 last; } location /ares-mobile-gateway { proxy_pass http://7.0.143.38:9080; #proxy_pass http://7.0.144.161:9080; } location /console { #proxy_pass http://7.0.143.38:9080; proxy_pass http://7.0.143.27:9080; } location /mbs-mbank/R { root html; autoindex on; } location /downloadFromPaperless { proxy_pass http://7.0.143.251:8080; } location ~/ares-behavior-analysis/\S*\.(do)?$ { proxy_pass http://7.0.143.129:8080; } location /portal{ root html; index index.html index.htm; } #配置文件下载 location /portal/download{ root html; #开启目录索引 autoindex on; } location /mbs-wbank{ root html/pwbank/; index index.html index.htm; } #跳转银联 #location /ares-channel-server{ # proxy_pass https://gateway.test.95516.com/; #} #转发到38服务器 location /mbs-resource { proxy_pass http://7.0.143.38:8080; } #转发到38服务器 location /mbs-resource-product { proxy_pass http://7.0.143.38:8080; } } server { listen 8002; server_name localhost; location /mbs-mbank { root html/; index index.html index.htm; } location ~/mbs-mbank/\S*\.(do|jsp)?$ { set $gateway "ares-mobile-gateway"; set $server "ares-channel-server"; rewrite ^/mbs-mbank/(.*)$ /$gateway/$1 last; } location /ares-mobile-gateway { #proxy_pass http://7.0.143.38:8080; #proxy_pass http://7.0.149.55:9080; proxy_pass http://7.0.144.161:9080; } } server { listen 9001; server_name localhost; location /mbs-mbank { root html/; index index.html index.htm; } location ~/mbs-mbank/\S*\.(do|jsp)?$ { set $gateway "ares-mobile-gateway"; rewrite ^/mbs-mbank/(.*)$ /$gateway/$1 last; } location /ares-mobile-gateway { proxy_pass http://7.0.143.38:9080; } location /ios3/profile.json { proxy_pass http://7.0.144.75:8088/ios3/profile.json; } location /android3/profile.json { proxy_pass http://7.0.144.75:8088/android3/profile.json; } location /mbs-resource { proxy_pass http://7.0.143.38:8080; } location /mbs-resource-product { proxy_pass http://7.0.143.38:8080; } } server { listen 8001; server_name localhost; location /mbs-mbank { root html/; index index.html index.htm; } location ~/mbs-mbank/\S*\.(do|jsp)?$ { set $gateway "ares-mobile-gateway"; set $server "ares-channel-server"; rewrite ^/mbs-mbank/(.*)$ /$gateway/$1 last; } location /ares-mobile-gateway { proxy_pass http://7.0.144.211:9080; #proxy_pass http://7.0.149.55:9080; } }

}

<!--/Note-->

内存及磁盘资源

client

用于调试,定位问题

配置块: server,location,http

client

请求中HTTP包体一律存储到内存buffer中,超出client

配置块: server,location,http

client

nginx接受请求中HTTP header部分时分配内存buffer大小

配置块: server,http

large

存储超大HTTP head的 buffer个数和每个buffer大小

配置块: server,http 默认: 4 8

client

存储HTTP包体的内存buffer大小

配置块: server,http,location 默认:8k/16k

client

HTTP包体的临时存放目录

配置块: server,http,location

防止一个目录文件数量太多,导致性能下降 client

如新上传HTTP包体使用0000123456作为临时文件名,则存放目录:/opt/nginx/client_temp/6/45/0000123456

connection

连接内存池大小

配置块: server,http, 默认 256

request

每个请求分配内存池大小

配置块: server,http, 默认 4 k

网络连接配置

client

读取HTTP header 的超时时间

配置块: server,http,location 默认 60

client

读取HTTP body 的超时时间

配置块: server,http,location 默认 60

send_timeout time

发送响应超时时间

配置块: server,http,location 默认 60

reset

连接超时后是否重置连接

配置块: server,http,location

lingering_close on | off | always

控制nginx关闭用户连接方式

配置块: server,http,location always :必须无条件处理连接上所有用户发送的数据 off:反之 on 中间值

lingering_time time

lingering_close 启用后,对于上传大文件很有用

配置块: server,http,location 默认 30s

lingering_timeout time

lingering_close 生效后,在关闭连接前,检查数据

配置块: server,http,location 默认 5s

keepalive_disable [ mise6 | safari | none] ...

对某些浏览器禁用keepalive功能

配置块: server,http,location 默认: keepalive_disable msie6 safari HTTP请求中keepalive功能是为了让多个请求复用一个HTTP长积极,提高服务器性能。 有些浏览器使用keepalive功能post请求处理有功能性问题。

keepalive_timeout time

keepalive 超时时间

配置块: server,http,location 默认: 75

keepalive_requests n

一个keepalive连接上允许承载的请求最大数

配置块: server,http,location 默认: 100

tcp_nodelay on | off

确定对keepalive连接是否使用TCP_NODELAY

配置块: server,http,location

tcp_nopush off | on

打开 tcp_nopush, 在发送响应时把整个响应包头放到一个TCP包中发送

配置块: server,http,location

MIME类型设置

types {...}

MIME type 与文件扩展的映射

配置块: server,http,location

default_type MIME-type

默认使用HTTP header Content-Type

配置块: server,http,location 默认 text/plain

types

每个散利痛占用内存大小

配置块: server,http,location 默认 32/64/12

types

散列表冲突率

配置块: server,http,location 默认: 102

对客户端请求的限制

limit_except method ... { ... }

按HTTP方法限制请求

分支主题

分支主题

修改返回错误码

error_page 404 =200 /error.gif

也可以不指定确切返回错误码,有重定向后实际处理结果决定

error_page 404 = /error.gif

请求重定向到另一个location中进行处理

location / { error

默认端口80

listen 127.0.0.1:8000; listen 8080; listen *:8080;

ipv6

listen [::]:8080;

其他参数

listen 127.0.0.1 default

相关思维导图模板

互联网JS闭包思维导图思维导图

树图思维导图提供 互联网JS闭包思维导图 在线思维导图免费制作,点击“编辑”按钮,可对 互联网JS闭包思维导图  进行在线思维导图编辑,本思维导图属于思维导图模板主题,文件编号是:55d06e6a9057a11e1d9c19f5ec8504bb

MySQL数据库项目式教程思维导图

树图思维导图提供 MySQL数据库项目式教程 在线思维导图免费制作,点击“编辑”按钮,可对 MySQL数据库项目式教程  进行在线思维导图编辑,本思维导图属于思维导图模板主题,文件编号是:896a5e6405ff361688d29af5c54c4d1d