Nginx 1 Nginx 20 30 CONTENTS 01 Nginx

  • Slides: 10
Download presentation
细说Nginx - 1 Nginx配置文件 20: 30开始

细说Nginx - 1 Nginx配置文件 20: 30开始

目录 CONTENTS 01. Nginx简介 02. 配置文件

目录 CONTENTS 01. Nginx简介 02. 配置文件

Nginx配置文件 - 主配置文件 ● 主配置文件位置在. /conf/nginx. conf ● 配置结构: http { //HTTP服务器对像 //HTTP全局配置 default_type

Nginx配置文件 - 主配置文件 ● 主配置文件位置在. /conf/nginx. conf ● 配置结构: http { //HTTP服务器对像 //HTTP全局配置 default_type application/octet-stream; client_max_body_size 50 m; include /www/server/panel/vhost/nginx/*. conf; / /支 持 i n c l u d e 语 句 . . . server { // 主机 listen 80; server_name test. com; root /wwwroot/test. com; include /www/server/panel/vhost/rewrite/test. com. conf; . . . } } / /支 持 i n c l u d e 语 句

Nginx配置文件 - HTTP全局配置 ● default_type 无法自动识别mime时的缺省响应类型 ● client_max_body_size 客户端最大请求体大小(如:上传文件) ● keepalive_timeout HTTP连接超时时间 ● fastcgi_connect_timeout

Nginx配置文件 - HTTP全局配置 ● default_type 无法自动识别mime时的缺省响应类型 ● client_max_body_size 客户端最大请求体大小(如:上传文件) ● keepalive_timeout HTTP连接超时时间 ● fastcgi_connect_timeout Fast. CGI连接超时时间 ● fastcgi_send_timeout Fast. CGI请求发送超时时间 ● fastcgi_read_timeout Fast. CGI请求接收超时时间 ● gzip/gzip_comp_level/gzip_types GZIP 压缩相关设置 ● log_format 日志格式定义,示例: 示例:log_format log_test '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for '"$request_time"';

Nginx配置文件 - log_format参数/变量 $remote_addr 客户端地址 $remote_user 客户端用户名称 $time_local 访问时间和时区 192. 168. 1. 22 -18/Jul/2020:

Nginx配置文件 - log_format参数/变量 $remote_addr 客户端地址 $remote_user 客户端用户名称 $time_local 访问时间和时区 192. 168. 1. 22 -18/Jul/2020: 17: 00: 01 +0800 $request 请求的URI和HTTP协议 $http_host 请求地址,即浏览器中你输入的地址(IP或域名) $status HTTP请求状态 $upstream_status upstream状态 $body_bytes_sent 发送给客户端文件内容大小 $http_referer $http_user_agent url跳转来源 用户终端浏览器等信息 "GET /article-10000. html HTTP/1. 1" www. wang. com 192. 168. 100 200 1547 https: //www. baidu. com/ "Mozilla/4. 0 (compatible; MSIE 8. 0; Windows NT 5. 1; Trident/4. 0; SV 1; GTB 7. 0; . NET 4. 0 C; $ssl_protocol SSL协议版本 TLSv 1 $ssl_cipher 交换数据中的算法 RC 4 -SHA $upstream_addr $request_time 后台upstream的地址,即真正提供服务的主机地址 整个请求的总时间 $upstream_response_time 请求过程中,upstream响应时间 10. 10. 100: 80 0. 205 0. 002

常用配置项 ● 获取真实IP: real_ip_header X-Forwarded-For; real_ip_recursive on;

常用配置项 ● 获取真实IP: real_ip_header X-Forwarded-For; real_ip_recursive on;