[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"knowledge-\u002Fapi\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Flogger":3,"knowledge-related-\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Flogger":1013,"knowledge-series-\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Flogger":1039},{"source":4,"connector":5,"page":6},"sqlite","better-sqlite3",{"path":7,"title":8,"description":9,"category":10,"tags":11,"date":14,"pinned":15,"draft":15,"body":16,"seo":1009,"stem":1010,"id":1011,"extension":1012},"\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Flogger","访问日志与错误日志","日志是 Nginx 排错的“第一现场”。一个优秀的日志策略既能完整保留请求上下文，又不会撑爆磁盘。下面从格式定制、存储轮转、错误分级三个维度详细讲解。","技能小册",[12,13],"nginx","logger","2020-02-29",false,{"type":17,"value":18,"toc":1002},"minimark",[19,22,25,35,45,50,121,145,149,362,386,390,430,441,445,455,476,501,558,578,587,599,603,606,614,621,629,632,662,670,679,683,707,711,738,824,827,836,853,860,865,886,892,930,953,956,960,998],[20,21,8],"h1",{"id":8},[23,24,9],"p",{},[26,27,29,30,34],"h3",{"id":28},"一日志格式定制log_format","一、日志格式定制（",[31,32,33],"code",{},"log_format","）",[23,36,37,38,41,42,44],{},"默认的 ",[31,39,40],{},"combined"," 格式包含基本字段，但往往不够用。你需要通过自定义 ",[31,43,33],{}," 组合变量，记录下真实客户端 IP、上游响应时间、负载均衡节点等关键信息。",[46,47,49],"h4",{"id":48},"_1-语法与使用","1. 语法与使用",[51,52,56],"pre",{"className":53,"code":54,"language":12,"meta":55,"style":55},"language-nginx shiki shiki-themes material-theme-lighter github-light github-dark","http {\n    log_format  main_ext  '$remote_addr - $remote_user [$time_local] '\n                          '\"$request\" $status $body_bytes_sent '\n                          '\"$http_referer\" \"$http_user_agent\" '\n                          'rt=$request_time uct=$upstream_connect_time '\n                          'uht=$upstream_header_time urt=$upstream_response_time '\n                          'upstream_addr=$upstream_addr';\n\n    access_log  \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log  main_ext  buffer=64k flush=5s;\n}\n","",[31,57,58,66,72,78,84,90,96,102,109,115],{"__ignoreMap":55},[59,60,63],"span",{"class":61,"line":62},"line",1,[59,64,65],{},"http {\n",[59,67,69],{"class":61,"line":68},2,[59,70,71],{},"    log_format  main_ext  '$remote_addr - $remote_user [$time_local] '\n",[59,73,75],{"class":61,"line":74},3,[59,76,77],{},"                          '\"$request\" $status $body_bytes_sent '\n",[59,79,81],{"class":61,"line":80},4,[59,82,83],{},"                          '\"$http_referer\" \"$http_user_agent\" '\n",[59,85,87],{"class":61,"line":86},5,[59,88,89],{},"                          'rt=$request_time uct=$upstream_connect_time '\n",[59,91,93],{"class":61,"line":92},6,[59,94,95],{},"                          'uht=$upstream_header_time urt=$upstream_response_time '\n",[59,97,99],{"class":61,"line":98},7,[59,100,101],{},"                          'upstream_addr=$upstream_addr';\n",[59,103,105],{"class":61,"line":104},8,[59,106,108],{"emptyLinePlaceholder":107},true,"\n",[59,110,112],{"class":61,"line":111},9,[59,113,114],{},"    access_log  \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log  main_ext  buffer=64k flush=5s;\n",[59,116,118],{"class":61,"line":117},10,[59,119,120],{},"}\n",[122,123,124,138],"ul",{},[125,126,127,129,130,133,134,137],"li",{},[31,128,33],{}," 必须在 ",[31,131,132],{},"http"," 块中定义，之后在 ",[31,135,136],{},"access_log"," 指令中引用指定格式。",[125,139,140,141,144],{},"每个变量之间有空格，末尾可用 ",[31,142,143],{},"\\"," 换行续写。",[46,146,148],{"id":147},"_2-常用变量速查","2. 常用变量速查",[150,151,152,168],"table",{},[153,154,155],"thead",{},[156,157,158,162,165],"tr",{},[159,160,161],"th",{},"变量名",[159,163,164],{},"含义",[159,166,167],{},"注意事项",[169,170,171,192,204,220,232,244,257,270,283,295,308,321,333,345],"tbody",{},[156,172,173,179,182],{},[174,175,176],"td",{},[31,177,178],{},"$remote_addr",[174,180,181],{},"直接连接的客户端 IP（可能是代理服务器的 IP）",[174,183,184,185,188,189],{},"要获取真实 IP，需配合 ",[31,186,187],{},"real_ip_header"," 或记录 ",[31,190,191],{},"$http_x_forwarded_for",[156,193,194,198,201],{},[174,195,196],{},[31,197,191],{},[174,199,200],{},"代理链中原始客户端的 IP 列表，通常取第一个",[174,202,203],{},"该头可被客户端伪造，须在可信代理处清除并追加",[156,205,206,211,217],{},[174,207,208],{},[31,209,210],{},"$request",[174,212,213,214],{},"原始的请求行，如 ",[31,215,216],{},"GET \u002Findex.html HTTP\u002F1.1",[174,218,219],{},"包含方法和协议版本",[156,221,222,227,230],{},[174,223,224],{},[31,225,226],{},"$status",[174,228,229],{},"响应状态码",[174,231],{},[156,233,234,239,242],{},[174,235,236],{},[31,237,238],{},"$body_bytes_sent",[174,240,241],{},"发送给客户端的 Body 字节数，不含响应头",[174,243],{},[156,245,246,251,254],{},[174,247,248],{},[31,249,250],{},"$request_time",[174,252,253],{},"从接收客户端第一个字节到发送完最后一个字节的总耗时（秒）",[174,255,256],{},"包含网络和 Nginx 内部处理时间",[156,258,259,264,267],{},[174,260,261],{},[31,262,263],{},"$upstream_connect_time",[174,265,266],{},"与上游建立连接耗时（秒）",[174,268,269],{},"需要反向代理模块",[156,271,272,277,280],{},[174,273,274],{},[31,275,276],{},"$upstream_header_time",[174,278,279],{},"从上游接收到响应头的耗时（秒）",[174,281,282],{},"同上",[156,284,285,290,293],{},[174,286,287],{},[31,288,289],{},"$upstream_response_time",[174,291,292],{},"从上游接收完整响应的总耗时（秒）",[174,294,282],{},[156,296,297,302,305],{},[174,298,299],{},[31,300,301],{},"$upstream_addr",[174,303,304],{},"上游服务器的地址和端口",[174,306,307],{},"记录请求实际发给了哪个后端，用于排查负载不均",[156,309,310,315,318],{},[174,311,312],{},[31,313,314],{},"$upstream_status",[174,316,317],{},"上游返回的状态码",[174,319,320],{},"判断后端是否健康",[156,322,323,328,331],{},[174,324,325],{},[31,326,327],{},"$http_referer",[174,329,330],{},"请求头 Referer",[174,332],{},[156,334,335,340,343],{},[174,336,337],{},[31,338,339],{},"$http_user_agent",[174,341,342],{},"请求头 User-Agent",[174,344],{},[156,346,347,356,359],{},[174,348,349,352,353],{},[31,350,351],{},"$ssl_cipher"," \u002F ",[31,354,355],{},"$ssl_protocol",[174,357,358],{},"当前连接使用的加密套件和协议",[174,360,361],{},"排查 SSL 相关问题",[23,363,364,368,369,372,373,376,377,379,380,382,383,385],{},[365,366,367],"strong",{},"记录真实 IP 的最佳实践","：在反向代理处设置 ",[31,370,371],{},"proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;"," 和 ",[31,374,375],{},"proxy_set_header X-Real-IP $remote_addr;","，然后在日志中记录 ",[31,378,191],{}," 或使用 ",[31,381,187],{}," 指令覆盖 ",[31,384,178],{},"。这样即使经过多层代理，也能找到原始客户端。",[46,387,389],{"id":388},"_3-示例排查性能瓶颈的增强日志","3. 示例：排查性能瓶颈的增强日志",[51,391,393],{"className":53,"code":392,"language":12,"meta":55,"style":55},"log_format perf '$remote_addr [$time_local] '\n                '\"$request\" $status $body_bytes_sent '\n                'ref=\"$http_referer\" '\n                'rt=$request_time '\n                'ups_resp_time=$upstream_response_time '\n                'ups_addr=$upstream_addr '\n                'ups_status=$upstream_status';\n",[31,394,395,400,405,410,415,420,425],{"__ignoreMap":55},[59,396,397],{"class":61,"line":62},[59,398,399],{},"log_format perf '$remote_addr [$time_local] '\n",[59,401,402],{"class":61,"line":68},[59,403,404],{},"                '\"$request\" $status $body_bytes_sent '\n",[59,406,407],{"class":61,"line":74},[59,408,409],{},"                'ref=\"$http_referer\" '\n",[59,411,412],{"class":61,"line":80},[59,413,414],{},"                'rt=$request_time '\n",[59,416,417],{"class":61,"line":86},[59,418,419],{},"                'ups_resp_time=$upstream_response_time '\n",[59,421,422],{"class":61,"line":92},[59,423,424],{},"                'ups_addr=$upstream_addr '\n",[59,426,427],{"class":61,"line":98},[59,428,429],{},"                'ups_status=$upstream_status';\n",[23,431,432,433,436,437,440],{},"通过 ",[31,434,435],{},"rt"," 与 ",[31,438,439],{},"ups_resp_time"," 的对比，可以快速判断耗时究竟在 Nginx 本身还是上游服务。",[26,442,444],{"id":443},"二日志路径与轮转","二、日志路径与轮转",[46,446,448,449,436,451,454],{"id":447},"_1-access_log-与-error_log-配置","1. ",[31,450,136],{},[31,452,453],{},"error_log"," 配置",[23,456,457,462,465,466,468,469,468,472,475],{},[365,458,459,460],{},"访问日志 ",[31,461,136],{},[463,464],"br",{},"\n可用在 ",[31,467,132],{},", ",[31,470,471],{},"server",[31,473,474],{},"location"," 上下文，支持以下功能：",[51,477,479],{"className":53,"code":478,"language":12,"meta":55,"style":55},"access_log \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log main_ext;           # 基本用法\naccess_log \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log main_ext buffer=64k flush=5s;  # 缓冲与刷新\naccess_log \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log main_ext gzip=9;    # gzip 压缩（需编译支持）\naccess_log off;                                           # 关闭日志（提升性能）\n",[31,480,481,486,491,496],{"__ignoreMap":55},[59,482,483],{"class":61,"line":62},[59,484,485],{},"access_log \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log main_ext;           # 基本用法\n",[59,487,488],{"class":61,"line":68},[59,489,490],{},"access_log \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log main_ext buffer=64k flush=5s;  # 缓冲与刷新\n",[59,492,493],{"class":61,"line":74},[59,494,495],{},"access_log \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log main_ext gzip=9;    # gzip 压缩（需编译支持）\n",[59,497,498],{"class":61,"line":80},[59,499,500],{},"access_log off;                                           # 关闭日志（提升性能）\n",[122,502,503,515,523],{},[125,504,505,510,511,514],{},[365,506,507],{},[31,508,509],{},"buffer","：日志先写入内存缓冲区，达到大小或到达 ",[31,512,513],{},"flush"," 时间后才刷入磁盘，减少 I\u002FO。",[125,516,517,522],{},[365,518,519],{},[31,520,521],{},"gzip","：使用 zlib 动态压缩，适合大流量站点，注意对 CPU 的影响。",[125,524,525,528,529],{},[365,526,527],{},"多日志","：可以用不同格式记录不同类型的请求，例如限制日志只记录 5xx 错误：\n",[51,530,532],{"className":53,"code":531,"language":12,"meta":55,"style":55},"map $status $loggable {\n    ~^[5]  1;\n    default 0;\n}\naccess_log \u002Fvar\u002Flog\u002Fnginx\u002Ferror_traffic.log main_ext if=$loggable;\n",[31,533,534,539,544,549,553],{"__ignoreMap":55},[59,535,536],{"class":61,"line":62},[59,537,538],{},"map $status $loggable {\n",[59,540,541],{"class":61,"line":68},[59,542,543],{},"    ~^[5]  1;\n",[59,545,546],{"class":61,"line":74},[59,547,548],{},"    default 0;\n",[59,550,551],{"class":61,"line":80},[59,552,120],{},[59,554,555],{"class":61,"line":86},[59,556,557],{},"access_log \u002Fvar\u002Flog\u002Fnginx\u002Ferror_traffic.log main_ext if=$loggable;\n",[23,559,560,565,567,568,468,571,468,573,468,575,577],{},[365,561,562,563],{},"错误日志 ",[31,564,453],{},[463,566],{},"\n记录服务器运行期间的错误、警告及调试信息，支持 ",[31,569,570],{},"main",[31,572,132],{},[31,574,471],{},[31,576,474],{}," 多级覆盖。",[51,579,581],{"className":53,"code":580,"language":12,"meta":55,"style":55},"error_log \u002Fvar\u002Flog\u002Fnginx\u002Ferror.log warn;\n",[31,582,583],{"__ignoreMap":55},[59,584,585],{"class":61,"line":62},[59,586,580],{},[122,588,589,592],{},[125,590,591],{},"支持输出到文件、stderr 或 syslog。",[125,593,594,595,598],{},"级别越宽泛（如 ",[31,596,597],{},"debug","），信息越多，但性能开销越大。",[46,600,602],{"id":601},"_2-日志轮转防止磁盘被吃满","2. 日志轮转：防止磁盘被吃满",[23,604,605],{},"Nginx 本身不会自动切割日志，需借助外部工具。",[607,608,610,611],"h5",{"id":609},"_1-使用-logrotate","(1) 使用 ",[31,612,613],{},"logrotate",[23,615,616,617,620],{},"这是 Linux 下最标准的方式。创建一个配置文件 ",[31,618,619],{},"\u002Fetc\u002Flogrotate.d\u002Fnginx","：",[51,622,627],{"className":623,"code":625,"language":626},[624],"language-text","\u002Fvar\u002Flog\u002Fnginx\u002F*.log {\n    daily                    # 每天切割\n    missingok                # 日志文件不存在时不报错\n    rotate 30                # 保留 30 份\n    compress                 # 压缩旧日志\n    delaycompress            # 延迟压缩，让刚切割的文件不被压缩（方便查看）\n    notifempty               # 日志为空则不切割\n    create 640 nginx adm     # 创建新文件的权限和属主\n    sharedscripts\n    postrotate\n        if [ -f \u002Fvar\u002Frun\u002Fnginx.pid ]; then\n            kill -USR1 `cat \u002Fvar\u002Frun\u002Fnginx.pid`\n        fi\n    endscript\n}\n","text",[31,628,625],{"__ignoreMap":55},[23,630,631],{},"关键点：",[122,633,634,648,655],{},[125,635,636,639,640,643,644,647],{},[31,637,638],{},"postrotate"," 中的 ",[31,641,642],{},"kill -USR1"," 通知 Nginx 重新打开日志文件。Nginx 收到 ",[31,645,646],{},"USR1"," 信号后，会关闭并重新打开所有日志文件，避免写入被删除的文件描述符。",[125,649,650,651,654],{},"可以通过执行 ",[31,652,653],{},"logrotate -d \u002Fetc\u002Flogrotate.d\u002Fnginx"," 进行调试测试。",[125,656,657,658,661],{},"实际执行：",[31,659,660],{},"logrotate -f \u002Fetc\u002Flogrotate.d\u002Fnginx"," 可强制立即切割一次。",[607,663,665,666,669],{"id":664},"_2-使用-cron-脚本不推荐除非无-logrotate","(2) 使用 ",[31,667,668],{},"cron"," 脚本（不推荐，除非无 logrotate）",[23,671,672,673,372,676,678],{},"可以写一个简单的 bash 脚本，利用 ",[31,674,675],{},"mv",[31,677,642],{},"，但需要处理好竞争和清空问题，logrotate 更可靠。",[46,680,682],{"id":681},"_3-日志管理高级建议","3. 日志管理高级建议",[122,684,685,696],{},[125,686,687,688,691,692,695],{},"搭配 ",[365,689,690],{},"PID 文件","：确保 ",[31,693,694],{},"pid \u002Frun\u002Fnginx.pid;"," 路径正确。",[125,697,698,699,702,703,706],{},"如果 Nginx 运行在容器中，通常将日志重定向到标准输出（",[31,700,701],{},"\u002Fdev\u002Fstdout","、",[31,704,705],{},"\u002Fdev\u002Fstderr","），由容器日志驱动统一收集和轮转。",[26,708,710],{"id":709},"三错误日志级别","三、错误日志级别",[23,712,713,714,468,716,468,719,468,722,468,725,468,728,468,731,468,734,737],{},"Nginx 错误日志级别从低到高分为：",[31,715,597],{},[31,717,718],{},"info",[31,720,721],{},"notice",[31,723,724],{},"warn",[31,726,727],{},"error",[31,729,730],{},"crit",[31,732,733],{},"alert",[31,735,736],{},"emerg","。设置越高，记录越少。",[150,739,740,750],{},[153,741,742],{},[156,743,744,747],{},[159,745,746],{},"级别",[159,748,749],{},"说明",[169,751,752,761,770,779,788,797,806,815],{},[156,753,754,758],{},[174,755,756],{},[31,757,597],{},[174,759,760],{},"最详细，包含内部处理流程、正则匹配等，用于开发调试",[156,762,763,767],{},[174,764,765],{},[31,766,718],{},[174,768,769],{},"一般信息，如配置加载、worker 进程启动等",[156,771,772,776],{},[174,773,774],{},[31,775,721],{},[174,777,778],{},"需要注意但非错误的事件，如重载配置、优雅关闭",[156,780,781,785],{},[174,782,783],{},[31,784,724],{},[174,786,787],{},"警告信息，如客户端超时、某些限制值被触及",[156,789,790,794],{},[174,791,792],{},[31,793,727],{},[174,795,796],{},"处理请求时的错误，如 500 错误、上游连接失败、SSL 握手失败",[156,798,799,803],{},[174,800,801],{},[31,802,730],{},[174,804,805],{},"较高严重级问题，如 socket 创建失败、共享内存不足",[156,807,808,812],{},[174,809,810],{},[31,811,733],{},[174,813,814],{},"需要立即动作的严重问题",[156,816,817,821],{},[174,818,819],{},[31,820,736],{},[174,822,823],{},"系统级不可用，如内存分配失败",[46,825,826],{"id":826},"配置示例",[51,828,830],{"className":53,"code":829,"language":12,"meta":55,"style":55},"error_log \u002Fvar\u002Flog\u002Fnginx\u002Ferror.log warn;   # 生产环境推荐\n",[31,831,832],{"__ignoreMap":55},[59,833,834],{"class":61,"line":62},[59,835,829],{},[23,837,838,839,842,843,845,846,848,849,852],{},"部分模块的调试信息（如 rewrite）需在编译时指定 ",[31,840,841],{},"--with-debug","，并在运行时使用 ",[31,844,453],{}," 设置 ",[31,847,597],{}," 级别配合 ",[31,850,851],{},"debug_connection"," 过滤。",[46,854,856,857,859],{"id":855},"何时开启-debug-日志","何时开启 ",[31,858,597],{}," 日志？",[23,861,862,620],{},[365,863,864],{},"仅在以下场景短暂启用，且最好针对特定 IP",[122,866,867,877,880,883],{},[125,868,869,870,873,874,876],{},"复杂的 ",[31,871,872],{},"rewrite"," 或 ",[31,875,474],{}," 不按预期匹配，需要知道内部跳转细节。",[125,878,879],{},"排查反向代理缓存不生效的问题。",[125,881,882],{},"SSL 握手失败，需要了解具体算法协商过程。",[125,884,885],{},"第三方模块的行为异常。",[23,887,888,891],{},[365,889,890],{},"开启方法","（假设已经编译了 debug 支持）：",[51,893,895],{"className":53,"code":894,"language":12,"meta":55,"style":55},"error_log \u002Fvar\u002Flog\u002Fnginx\u002Fdebug.log debug;   # 全局开启，极耗性能，不推荐\n\n# 更好的方式：仅记录特定客户端的调试信息\nevents {\n    debug_connection 192.168.1.100;   # 仅对该 IP 输出 debug 日志\n    debug_connection 10.0.0.0\u002F8;\n}\n",[31,896,897,902,906,911,916,921,926],{"__ignoreMap":55},[59,898,899],{"class":61,"line":62},[59,900,901],{},"error_log \u002Fvar\u002Flog\u002Fnginx\u002Fdebug.log debug;   # 全局开启，极耗性能，不推荐\n",[59,903,904],{"class":61,"line":68},[59,905,108],{"emptyLinePlaceholder":107},[59,907,908],{"class":61,"line":74},[59,909,910],{},"# 更好的方式：仅记录特定客户端的调试信息\n",[59,912,913],{"class":61,"line":80},[59,914,915],{},"events {\n",[59,917,918],{"class":61,"line":86},[59,919,920],{},"    debug_connection 192.168.1.100;   # 仅对该 IP 输出 debug 日志\n",[59,922,923],{"class":61,"line":92},[59,924,925],{},"    debug_connection 10.0.0.0\u002F8;\n",[59,927,928],{"class":61,"line":98},[59,929,120],{},[122,931,932,943],{},[125,933,934,936,937,939,940,942],{},[31,935,851],{}," 需配合 ",[31,938,453],{}," 级别设为 ",[31,941,597],{}," 起效。",[125,944,945,946,949,950,952],{},"调试结束后务必",[365,947,948],{},"立即关闭","或恢复为 ",[31,951,724],{},"，并清理 debug 日志文件，否则磁盘和 CPU 会迅速耗尽。",[23,954,955],{},"把格式设得恰到好处，将轮转配置到位，并熟练掌握错误日志级别的切换，你的 Nginx 就能始终保持“透明”——任何请求的来龙去脉、任何错误的蛛丝马迹都有据可查。这既是运维的基本功，也是快速止损的关键能力。",[957,958,959],"h2",{"id":959},"参考文献",[150,961,962,971],{},[153,963,964],{},[156,965,966,969],{},[159,967,968],{},"资料",[159,970,749],{},[169,972,973,987],{},[156,974,975,984],{},[174,976,977],{},[978,979,983],"a",{"href":980,"rel":981},"https:\u002F\u002Fnginx.org\u002Fen\u002Fdocs\u002F",[982],"nofollow","nginx 文档",[174,985,986],{},"官方",[156,988,989,995],{},[174,990,991],{},[978,992,994],{"href":993},"\u002Fknowledge\u002Fbooklet\u002Fuphold","运维导读",[174,996,997],{},"学习路径",[999,1000,1001],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":55,"searchDepth":68,"depth":68,"links":1003},[1004,1006,1007,1008],{"id":28,"depth":74,"text":1005},"一、日志格式定制（log_format）",{"id":443,"depth":74,"text":444},{"id":709,"depth":74,"text":710},{"id":959,"depth":68,"text":959},{"title":8,"description":9},"knowledge\u002Fbooklet\u002Fuphold\u002FNginx\u002Flogger","knowledge\u002Fknowledge\u002Fbooklet\u002Fuphold\u002FNginx\u002Flogger.md","md",{"items":1014},[1015,1019,1023,1027,1031,1035],{"path":1016,"title":1017,"description":1018,"category":10,"score":92},"\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Fse","安全基础","Nginx 作为流量的总入口，安全配置是防线第一关。以下从六个基础维度加固你的服务，既实用又立竿见影。",{"path":1020,"title":1021,"description":1022,"category":10,"score":92},"\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Fconfig","配置文件结构与语法","下面我们深入到 Nginx 的配置核心——配置文件的结构、语法和变量系统。这一部分是你驾驭 Nginx 的“语法手册”。",{"path":1024,"title":1025,"description":1026,"category":10,"score":92},"\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Fcore","核心模块与常见指令详解","深入 Nginx 的指令层，是配置落地的关键。下面按功能模块拆解，每个指令都说明含义、语法、典型示例，并点出极易踩坑的地方。",{"path":1028,"title":1029,"description":1030,"category":10,"score":92},"\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Fbase","Nginx 核心概念","Nginx 是一款高性能的 HTTP 和反向代理服务器。学习路径见 运维导读。它的强大并发能力与灵活的扩展性根植于少数几个核心设计。理解这些底层原理，后续的配置、调优和排障都会变得通透。",{"path":1032,"title":1033,"description":1034,"category":10,"score":92},"\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Fseror","常见故障排查思路","故障排查的关键是快速定位，而非盲目重试。下面按最常见的五种现象归类，每一种都给出清晰的排查路径和解决思路。",{"path":1036,"title":1037,"description":1038,"category":10,"score":92},"\u002Fknowledge\u002Fbooklet\u002Fuphold\u002Fnginx\u002Fpre","性能调优基础","性能调优的目标是：用有限的资源，支撑更高的并发、更快的响应、更稳的服务。下面按优化维度，逐一拆解原理和配置要诀。",{"series":1040,"title":12,"items":1041,"index":74,"prev":1055,"next":1056},"booklet\u002Fuphold\u002Fnginx",[1042,1044,1046,1048,1049,1051,1053],{"path":1028,"title":1029,"date":1043,"pinned":15},"2023-04-03",{"path":1020,"title":1021,"date":1045,"pinned":15},"2023-11-24",{"path":1024,"title":1025,"date":1047,"pinned":15},"2023-04-25",{"path":7,"title":8,"date":14,"pinned":15},{"path":1036,"title":1037,"date":1050,"pinned":15},"2020-07-11",{"path":1016,"title":1017,"date":1052,"pinned":15},"2024-12-02",{"path":1032,"title":1033,"date":1054,"pinned":15},"2020-09-18",{"path":1024,"title":1025,"date":1047,"pinned":15},{"path":1036,"title":1037,"date":1050,"pinned":15}]