{"id":58259,"date":"2025-08-16T07:20:29","date_gmt":"2025-08-15T23:20:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/58259.html"},"modified":"2025-08-16T07:20:29","modified_gmt":"2025-08-15T23:20:29","slug":"nginx-%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%b8%b8%e7%94%a8%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/58259.html","title":{"rendered":"Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c"},"content":{"rendered":"<h3>\u4e00. Nginx \u5e38\u7528\u914d\u7f6e<\/h3>\n<h4>1. Nginx \u603b\u914d\u7f6e\u6587\u4ef6<\/h4>\n<p>nginx \u5b89\u88c5\u76ee\u5f55\u4e0b\u7684 nginx.conf \u6587\u4ef6:<\/p>\n<p># \u6307\u5b9a Nginx worker \u8fdb\u7a0b\u8fd0\u884c\u7684\u7cfb\u7edf\u7528\u6237<br \/>\nuser  nginx;<br \/>\n# \u81ea\u52a8\u6839\u636e CPU \u6838\u5fc3\u6570\u542f\u52a8\u76f8\u5e94\u6570\u91cf\u7684 worker \u8fdb\u7a0b&#xff0c;\u5145\u5206\u5229\u7528\u591a\u6838\u3002<br \/>\nworker_processes  auto;<br \/>\n# \u81ea\u52a8\u5c06 worker \u8fdb\u7a0b\u7ed1\u5b9a\u5230\u7279\u5b9a CPU \u6838\u5fc3&#xff0c;\u51cf\u5c11 CPU \u7f13\u5b58\u5931\u6548&#xff0c;\u63d0\u9ad8\u6027\u80fd\u3002<br \/>\nworker_cpu_affinity auto;<\/p>\n<p># \u9519\u8bef\u65e5\u5fd7\u8def\u5f84\u548c\u65e5\u5fd7\u7ea7\u522b<br \/>\nerror_log  \/var\/log\/nginx\/error.log warn;<br \/>\n# \u4fdd\u5b58 Nginx \u4e3b\u8fdb\u7a0b PID \u6587\u4ef6\u7684\u4f4d\u7f6e&#xff0c;\u65b9\u4fbf\u7ba1\u7406\u3002<br \/>\npid        \/var\/run\/nginx.pid;<\/p>\n<p># \u4e8b\u4ef6\u6bb5<br \/>\nevents {<br \/>\n    # \u6bcf\u4e2a worker \u8fdb\u7a0b\u5141\u8bb8\u540c\u65f6\u5904\u7406\u7684\u6700\u5927\u8fde\u63a5\u6570<br \/>\n    worker_connections  4096;<br \/>\n    # \u907f\u514d\u591a\u4e2a worker \u540c\u65f6\u4e89\u62a2\u65b0\u8fde\u63a5&#xff0c;\u51cf\u5c11\u60ca\u7fa4\u6548\u5e94&#xff08;\u9002\u5408\u9ad8\u5e76\u53d1&#xff09;<br \/>\n    accept_mutex on;<br \/>\n    # worker \u4e00\u6b21\u5c3d\u91cf\u591a\u63a5\u6536\u8fde\u63a5&#xff0c;\u800c\u4e0d\u662f\u4e00\u6b21\u53ea\u63a5\u4e00\u4e2a&#xff0c;\u63d0\u9ad8\u541e\u5410\u91cf<br \/>\n    multi_accept on;<br \/>\n}<\/p>\n<p># HTTP \u6bb5<br \/>\nhttp {<br \/>\n    # \u52a0\u8f7d\u6587\u4ef6\u7c7b\u578b\u4e0e MIME \u7c7b\u578b\u7684\u6620\u5c04\u8868\u3002<br \/>\n    include       \/etc\/nginx\/mime.types;<br \/>\n    # \u9ed8\u8ba4 MIME \u7c7b\u578b&#xff08;\u627e\u4e0d\u5230\u7c7b\u578b\u65f6\u6309\u4e8c\u8fdb\u5236\u6d41\u5904\u7406&#xff09;\u3002<br \/>\n    default_type  application\/octet-stream;<\/p>\n<p>    # \u5b9a\u4e49\u8bbf\u95ee\u65e5\u5fd7\u7684\u683c\u5f0f<br \/>\n    log_format  main  &#039;$remote_addr &#8211; $remote_user [$time_local] &#034;$request&#034; &#039;<br \/>\n                      &#039;$status $body_bytes_sent &#034;$http_referer&#034; &#039;<br \/>\n                      &#039;&#034;$http_user_agent&#034; &#034;$http_x_forwarded_for&#034;&#039;;<br \/>\n    # \u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\u4f4d\u7f6e<br \/>\n    access_log  \/var\/log\/nginx\/access.log  main;<\/p>\n<p>    # \u5173\u95ed\u54cd\u5e94\u5934\u4e2d Nginx \u7248\u672c\u53f7&#xff0c;\u9632\u6b62\u66b4\u9732\u7248\u672c\u4fe1\u606f<br \/>\n    server_tokens  off; <\/p>\n<p>    # \u5f00\u542f\u96f6\u62f7\u8d1d\u673a\u5236&#xff0c;\u63d0\u9ad8\u9759\u6001\u6587\u4ef6\u4f20\u8f93\u6027\u80fd\u3002<br \/>\n    sendfile        on;<br \/>\n    #tcp_nopush     on;<\/p>\n<p>    # \u9650\u5236\u5ba2\u6237\u7aef\u8bf7\u6c42\u4f53\u5927\u5c0f&#xff08;\u4e3b\u8981\u5f71\u54cd\u6587\u4ef6\u4e0a\u4f20&#xff09;<br \/>\n    client_max_body_size 50m;<br \/>\n    # \u63a5\u4fdd\u6301\u65f6\u95f4&#xff08;\u79d2&#xff09;&#xff0c;\u8d85\u8fc7\u8fd9\u4e2a\u65f6\u95f4\u7a7a\u95f2\u8fde\u63a5\u4f1a\u5173\u95ed\u3002<br \/>\n    keepalive_timeout  65;<\/p>\n<p>    # \u542f\u7528 Gzip \u538b\u7f29&#xff0c;\u51cf\u5c11\u4f20\u8f93\u4f53\u79ef\u3002<br \/>\n    gzip on;<br \/>\n    # \u5c0f\u4e8e 1KB \u7684\u54cd\u5e94\u4e0d\u538b\u7f29\u3002<br \/>\n    gzip_min_length 1k;<br \/>\n    # \u538b\u7f29\u7ea7\u522b&#xff08;1~9&#xff0c;\u6570\u5b57\u8d8a\u5927\u538b\u7f29\u6bd4\u8d8a\u9ad8\u4f46 CPU \u5f00\u9500\u8d8a\u5927&#xff0c;6 \u662f\u5e73\u8861\u503c&#xff09;\u3002<br \/>\n    gzip_comp_level 6;<br \/>\n    # \u8ba9\u4ee3\u7406\u7f13\u5b58\u77e5\u9053\u6709\u538b\u7f29\u7248\u672c\u3002<br \/>\n    gzip_vary on;<br \/>\n    # \u538b\u7f29\u6570\u636e\u7684\u7f13\u51b2\u533a\u6570\u91cf\u548c\u5927\u5c0f\u3002<br \/>\n    gzip_buffers 16 8k;<br \/>\n    # \u5b9a\u4e49\u8981\u538b\u7f29\u7684\u5185\u5bb9\u7c7b\u578b&#xff08;\u6587\u672c\u7c7b\u3001JSON\u3001JS\u3001XML\u3001\u90e8\u5206\u56fe\u7247\u7b49&#xff09;\u3002<br \/>\n    gzip_types text\/plain text\/css application\/json application\/javascript text\/xml application\/xml application\/xml&#043;rss text\/javascript image\/jpeg image\/gif  application\/x-protobuf application\/octet-stream;<\/p>\n<p>    # \u8f7d\u5165 \/etc\/nginx\/conf.d\/ \u76ee\u5f55\u4e0b\u7684\u6240\u6709 .conf \u6587\u4ef6&#xff0c;\u901a\u5e38\u8fd9\u91cc\u4f1a\u653e\u5404\u4e2a\u7ad9\u70b9\u6216\u670d\u52a1\u7684\u5177\u4f53 server \u914d\u7f6e\u3002<br \/>\n    include \/etc\/nginx\/conf.d\/*.conf;<\/p>\n<p>}<\/p>\n<h4>2. Nginx \u5b50\u6587\u4ef6<\/h4>\n<p>nginx \u5b89\u88c5\u76ee\u5f55\u4e0b\u7684 conf.d \u6587\u4ef6\u5939\u4e0b\u53ef\u4ee5\u653e\u7f6e\u591a\u4e2a\u5b50\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u5982: default.conf:<\/p>\n<p># \u5b9a\u4e49\u4e00\u4e2a\u540d\u5b57\u53eb ashen_servers \u7684\u4e0a\u6e38\u670d\u52a1\u5668\u7ec4<br \/>\nupstream ashen_servers {<br \/>\n    # \u6bcf\u4e2a ashen00x \u662f\u4e00\u4e2a\u540e\u7aef\u670d\u52a1&#xff08;IP \u6216\u4e3b\u673a\u540d&#xff09;&#xff0c;\u7aef\u53e3\u662f 8091\u3002<br \/>\n    # \u8d1f\u8f7d\u5747\u8861\u6743\u91cd&#xff08;\u8fd9\u91cc\u90fd\u662f 1&#xff0c;\u8868\u793a\u5747\u5300\u5206\u914d\u8bf7\u6c42&#xff09;\u3002<br \/>\n    server ashen001:8091  weight&#061;1;<br \/>\n    server ashen002:8091  weight&#061;1;<br \/>\n    server ashen003:8091  weight&#061;1;<br \/>\n}<\/p>\n<p>server {<br \/>\n    # \u5f00\u542f 443 \u7aef\u53e3&#xff0c;\u652f\u6301 HTTP\/2 &#043; SSL\u3002<br \/>\n    listen 443 http2 ssl;<br \/>\n    # IPv6 \u652f\u6301\u3002<br \/>\n    listen [::]:443 http2 ssl;<br \/>\n    # \u8be5\u865a\u62df\u4e3b\u673a\u5339\u914d www.ashentest.com \u57df\u540d\u8bf7\u6c42<br \/>\n    server_name www.ashentest.com;<\/p>\n<p>    # \u6307\u5b9a SSL \u8bc1\u4e66\u548c\u79c1\u94a5\u8def\u5f84<br \/>\n    ssl_certificate \/etc\/nginx\/ssl\/www.ashentest.com.pem;<br \/>\n    ssl_certificate_key \/etc\/nginx\/ssl\/www.ashentest.com.key;<\/p>\n<p>    # ssl\u9a8c\u8bc1\u76f8\u5173\u914d\u7f6e<br \/>\n    # SSL \u4f1a\u8bdd\u7f13\u5b58\u6709\u6548\u671f 5 \u5206\u949f\u3002<br \/>\n    ssl_session_timeout  5m;<br \/>\n    # \u52a0\u5bc6\u5957\u4ef6&#xff0c;\u7981\u6b62\u5f31\u52a0\u5bc6\u7b97\u6cd5&#xff08;!\u5f00\u5934\u7684\u8868\u793a\u7981\u7528&#xff09;\u3002<br \/>\n    # \u9996\u9009\u5957\u4ef6&#xff1a;\u692d\u5706\u66f2\u7ebf Diffie-Hellman \u4e34\u65f6\u5bc6\u94a5\u4ea4\u6362&#xff08;ECDHE&#xff09;\u3001RSA \u8eab\u4efd\u8ba4\u8bc1\u3001AES128 \u4f4d\u52a0\u5bc6&#xff08;GCM \u6a21\u5f0f&#xff09;\u3001SHA256 \u6d88\u606f\u8ba4\u8bc1\u3002<br \/>\n    # ECDHE&#xff1a;\u4e34\u65f6\u5bc6\u94a5\u4ea4\u6362&#xff0c;\u9632\u6b62\u5bc6\u94a5\u88ab\u957f\u671f\u7a83\u53d6\u3002<br \/>\n    # ECDH&#xff1a;\u692d\u5706\u66f2\u7ebf Diffie-Hellman&#xff08;\u975e\u4e34\u65f6\u5bc6\u94a5&#xff09;\u3002<br \/>\n    # AES&#xff1a;AES \u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\u3002<br \/>\n    # HIGH&#xff1a;\u9ad8\u5f3a\u5ea6\u52a0\u5bc6\u5957\u4ef6&#xff08;OpenSSL \u5185\u7f6e\u6807\u7b7e&#xff09;\u3002<br \/>\n    # !NULL&#xff1a;\u7981\u7528\u4e0d\u52a0\u5bc6\u7684\u5957\u4ef6&#xff08;\u7eaf\u660e\u6587\u4f20\u8f93&#xff09;\u3002<br \/>\n    # !aNULL&#xff1a;\u7981\u7528\u533f\u540d\u8ba4\u8bc1\u7684\u5957\u4ef6&#xff08;\u65e0\u8eab\u4efd\u9a8c\u8bc1&#xff0c;\u5bb9\u6613\u4e2d\u95f4\u4eba\u653b\u51fb&#xff09;\u3002<br \/>\n    # !MD5&#xff1a;\u7981\u7528\u57fa\u4e8e MD5 \u7684\u5957\u4ef6&#xff08;MD5 \u5df2\u88ab\u653b\u7834&#xff09;\u3002<br \/>\n    # !ADH&#xff1a;\u7981\u7528\u533f\u540d Diffie-Hellman\u3002<br \/>\n    # !RC4&#xff1a;\u7981\u7528 RC4 \u6d41\u52a0\u5bc6&#xff08;\u5df2\u4e0d\u5b89\u5168&#xff09;\u3002<br \/>\n    # !3DES&#xff1a;\u7981\u7528 3DES&#xff08;\u4e09\u91cd DES&#xff0c;\u52a0\u5bc6\u5f3a\u5ea6\u4f4e\u4e14\u6613\u53d7 Sweet32 \u653b\u51fb&#xff09;\u3002<br \/>\n    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!3DES;<br \/>\n    # \u5b89\u5168\u94fe\u63a5\u53ef\u9009\u7684\u52a0\u5bc6\u534f\u8bae<br \/>\n    # ssl_protocols TLSv1 TLSv1.1 TLSv1.2;<br \/>\n    # \u53ea\u5141\u8bb8 TLS 1.1 \u548c TLS 1.2&#xff08;TLS 1.0 \u5df2\u5e9f\u5f03&#xff09;<br \/>\n    # \u6307\u5b9a\u5141\u8bb8\u7684 TLS \u534f\u8bae\u7248\u672c\u3002<br \/>\n    # TLSv1.1&#xff1a;\u6bd4 TLSv1.0 \u5b89\u5168&#xff0c;\u4f46\u73b0\u5728\u5df2\u9010\u6b65\u5f03\u7528\u3002<br \/>\n    # TLSv1.2&#xff1a;\u76ee\u524d\u4e3b\u6d41\u5b89\u5168\u7248\u672c&#xff08;\u652f\u6301 AES-GCM\u3001SHA256 \u7b49\u73b0\u4ee3\u5957\u4ef6&#xff09;\u3002<br \/>\n    ssl_protocols TLSv1.1 TLSv1.2;<br \/>\n    # \u670d\u52a1\u5668\u4f18\u5148\u4f7f\u7528\u81ea\u5df1\u9009\u62e9\u7684\u52a0\u5bc6\u7b97\u6cd5&#xff08;\u589e\u5f3a\u5b89\u5168&#xff09;<br \/>\n    ssl_prefer_server_ciphers on;<\/p>\n<p>    # \u6700\u5927\u8bf7\u6c42\u4f53&#xff08;\u6587\u4ef6\u4e0a\u4f20\u7b49&#xff09;300MB<br \/>\n    client_max_body_size 300m;<\/p>\n<p>    # \u9ed8\u8ba4\u9996\u9875\u6587\u4ef6\u4f18\u5148\u7ea7&#xff1a;index.html \u2192 index.htm \u2192 index.nginx-debian.html<br \/>\n    index index.html index.htm index.nginx-debian.html;<\/p>\n<p>    # \u6839\u76ee\u5f55<br \/>\n    location \/ {<br \/>\n        root   \/usr\/share\/nginx\/html;<br \/>\n        index  index.html index.htm;<br \/>\n    }<\/p>\n<p>    # \u524d\u7aef\u914d\u7f6e<br \/>\n    location \/webtest {<br \/>\n        alias \/usr\/share\/nginx\/html\/webtest;<br \/>\n        index index.html index.htm;<br \/>\n    }<\/p>\n<p>    # \u914d\u7f6e\u8de8\u57df\u7684\u524d\u7aef\u670d\u52a1<br \/>\n    location \/yunkongzhixing{<br \/>\n        add_header Access-Control-Allow-Origin *;<br \/>\n        add_header Access-Control-Allow-Methods &#039;GET, POST, OPTIONS&#039;;<br \/>\n        add_header Access-Control-Allow-Headers &#039;DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization&#039;;<br \/>\n        if ($request_method &#061; &#039;OPTIONS&#039;) {<br \/>\n           return 204;<br \/>\n        }<br \/>\n        alias \/usr\/share\/nginx\/html\/yunkongzhixing;<br \/>\n        index index.html index.htm index.nginx-debian.html;<br \/>\n   }<\/p>\n<p>    # \u540e\u7aef\u914d\u7f6e<br \/>\n    location \/api-test {<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-Ip $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $remote_addr;<br \/>\n        proxy_pass http:\/\/192.168.1.111:8088\/api-test;<br \/>\n    }<\/p>\n<p>    # \u914d\u7f6e\u8d1f\u8f7d\u5747\u8861\u7684\u670d\u52a1<br \/>\n    location \/ashen {<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-Ip $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $remote_addr;<br \/>\n        proxy_pass http:\/\/ashen_servers\/ashen;<br \/>\n    }<\/p>\n<p>}<\/p>\n<p>server {<\/p>\n<p>    listen       80;<br \/>\n    server_name  localhost;<\/p>\n<p>        location \/ {<br \/>\n        root   \/usr\/share\/nginx\/html;<br \/>\n        index  index.html index.htm;<br \/>\n    }<\/p>\n<p>    # \u524d\u7aef\u914d\u7f6e<br \/>\n    location \/webtest {<br \/>\n        alias \/usr\/share\/nginx\/html\/webtest;<br \/>\n        index index.html index.htm;<br \/>\n    }<\/p>\n<p>    # \u540e\u7aef\u914d\u7f6e<br \/>\n    location \/api-test {<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-Ip $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $remote_addr;<br \/>\n        proxy_pass http:\/\/192.168.1.111:8088\/api-test;<br \/>\n    }<\/p>\n<p>    #error_page  404              \/404.html;<\/p>\n<p>    # redirect server error pages to the static page \/50x.html<\/p>\n<p>    # \u9519\u8bef\u9875\u9762<br \/>\n    # \u5f53\u8fd4\u56de 500\/502\/503\/504 \u9519\u8bef\u65f6&#xff0c;\u7528 \/usr\/share\/nginx\/html\/50x.html \u663e\u793a\u81ea\u5b9a\u4e49\u9519\u8bef\u9875\u9762\u3002<br \/>\n    error_page   500 502 503 504  \/50x.html;<br \/>\n    location &#061; \/50x.html {<br \/>\n        root   \/usr\/share\/nginx\/html;<br \/>\n    }<\/p>\n<p>}<\/p>\n<h3>\u4e8c. Nginx \u56db\u5c42\u4ee3\u7406<\/h3>\n<p>\u4e0a\u9762\u7684\u914d\u7f6e\u4e3b\u8981\u662f\u9488\u5bf9HTTP\u7684\u4e03\u5c42\u4ee3\u7406\u6a21\u5f0f, Nginx \u901a\u7528\u652f\u6301 \u56db\u5c42\u4ee3\u7406\u6a21\u5f0f:<\/p>\n<li>OSI \u6a21\u578b\u7684 \u7b2c\u4e03\u5c42&#xff1a;\u5e94\u7528\u5c42&#xff08;HTTP\u3001WebSocket\u3001SMTP \u7b49&#xff09;<\/li>\n<li>OSI \u6a21\u578b\u7684 \u7b2c\u56db\u5c42&#xff1a;\u4f20\u8f93\u5c42&#xff08;TCP\/UDP&#xff09;<\/li>\n<p>\u4e24\u5c42\u4ee3\u7406\u7684\u6838\u5fc3\u533a\u522b:<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u9879\u56db\u5c42\u4ee3\u7406&#xff08;L4&#xff09;\u4e03\u5c42\u4ee3\u7406&#xff08;L7&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u5904\u7406\u5c42\u7ea7<\/td>\n<td>\u53ea\u5904\u7406 TCP\/UDP \u6d41&#xff0c;\u4e0d\u89e3\u6790\u5e94\u7528\u5c42\u6570\u636e<\/td>\n<td>\u89e3\u6790 HTTP\/HTTPS \u7b49\u5e94\u7528\u5c42\u534f\u8bae<\/td>\n<\/tr>\n<tr>\n<td>Nginx \u6a21\u5757<\/td>\n<td>stream {}<\/td>\n<td>http {}<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u7406\u65b9\u5f0f<\/td>\n<td>\u7c7b\u4f3c IP:PORT \u7684\u8f6c\u53d1&#xff0c;\u900f\u660e\u4f20\u8f93<\/td>\n<td>\u57fa\u4e8e URL\u3001Host\u3001Header \u7b49\u505a\u8def\u7531<\/td>\n<\/tr>\n<tr>\n<td>\u80fd\u5426\u4fee\u6539\u6570\u636e<\/td>\n<td>\u274c \u4e0d\u80fd\u6539\u5e94\u7528\u5c42\u5185\u5bb9<\/td>\n<td>\u2705 \u53ef\u4ee5\u6539\u8bf7\u6c42\u5934\u3001\u54cd\u5e94\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td>\u6027\u80fd<\/td>\n<td>\u9ad8&#xff08;\u6570\u636e\u5305\u8f6c\u53d1\u5feb&#xff0c;\u5ef6\u8fdf\u4f4e&#xff09;<\/td>\n<td>\u7a0d\u4f4e&#xff08;\u8981\u89e3\u6790\u3001\u5904\u7406 HTTP \u5185\u5bb9&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5e38\u7528\u573a\u666f<\/td>\n<td>\u6570\u636e\u5e93\u4ee3\u7406\u3001TCP \u5e94\u7528\u3001\u8d1f\u8f7d\u5747\u8861\u3001SSL \u900f\u4f20<\/td>\n<td>Web \u53cd\u5411\u4ee3\u7406\u3001API \u7f51\u5173\u3001\u9759\u6001\u8d44\u6e90\u670d\u52a1<\/td>\n<\/tr>\n<tr>\n<td>\u8d1f\u8f7d\u5747\u8861\u7c92\u5ea6<\/td>\n<td>IP&#043;\u7aef\u53e3\u7ea7<\/td>\n<td>URL\u3001\u57df\u540d\u3001Header\u3001Cookie \u7ea7<\/td>\n<\/tr>\n<tr>\n<td>\u793a\u4f8b<\/td>\n<td>\u8f6c\u53d1 MySQL 3306\u3001Redis 6379\u3001HTTPS 443<\/td>\n<td>\u6839\u636e URL \u8f6c\u53d1 \/api \u7ed9\u540e\u7aef&#xff0c;\/static \u7ed9\u9759\u6001\u670d\u52a1\u5668<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u793a\u4f8b:<\/p>\n<p># \u56db\u5c42\u4ee3\u7406<br \/>\nstream {<\/p>\n<p>   # \u5bf9 ashen_server \u7684\u4ee3\u7406, \u9700\u8981\u8d1f\u8f7d\u5747\u8861\u5f00\u8d77 upstream<br \/>\n   upstream mongodb_server {<br \/>\n        server ashen001:8808;<br \/>\n        server ashen002:8808;<br \/>\n   }<\/p>\n<p>   server {<br \/>\n        listen 18808;<br \/>\n        proxy_pass ashen_server;<br \/>\n   }<\/p>\n<p># \u5bf9\u5355\u4e2a\u670d\u52a1\u8fdb\u53bb\u56db\u5c42\u4ee3\u7406<br \/>\n   server {<br \/>\n        listen 18848;<br \/>\n        proxy_pass docloud003:8848;<br \/>\n   }<\/p>\n<p>}<\/p>\n<h3>\u4e09.Tomcat \u548c Nginx \u542f\u7528 gzip \u538b\u7f29<\/h3>\n<h4>1.Nginx\u542f\u7528GZIP\u538b\u7f29<\/h4>\n<p>\u9700\u8981\u4fee\u6539 Nginx\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684conf\/nginx.conf\u6587\u4ef6<\/p>\n<p>\u6dfb\u52a0&#xff1a;<\/p>\n<p>     gzip on;<br \/>\n     gzip_vary on;<br \/>\n     gzip_buffers 16 8k;<br \/>\n     gzip_types text\/plain text\/css application\/json application\/javascript text\/xml application\/xml application\/xml&#043;rss text\/javascript image\/jpeg image\/gif image\/png;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815232018-689fc0b2b3572.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7136\u540e\u91cd\u542fNginx<\/p>\n<h4>2.Tomcat\u542f\u7528 gzip \u538b\u7f29<\/h4>\n<p>\u9700\u8981\u4fee\u6539tomcat\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684conf\/server.xml\u6587\u4ef6<\/p>\n<p><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>Connector<\/span> <span class=\"token attr-name\">port<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>8080<span class=\"token punctuation\">&#034;<\/span><\/span><br \/>\n  <span class=\"token attr-name\">protocol<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>HTTP\/1.1<span class=\"token punctuation\">&#034;<\/span><\/span><br \/>\n  <span class=\"token attr-name\">connectionTimeout<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>20000<span class=\"token punctuation\">&#034;<\/span><\/span><br \/>\n  <span class=\"token attr-name\">redirectPort<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>8443<span class=\"token punctuation\">&#034;<\/span><\/span><br \/>\n  <span class=\"token attr-name\">compression<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>on<span class=\"token punctuation\">&#034;<\/span><\/span><br \/>\n  <span class=\"token attr-name\">compressionMinSize<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>2048<span class=\"token punctuation\">&#034;<\/span><\/span><br \/>\n  <span class=\"token attr-name\">noCompressionUserAgents<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>gozilla, traviata<span class=\"token punctuation\">&#034;<\/span><\/span><br \/>\n  <span class=\"token attr-name\">compressableMimeType<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>text\/html,text\/xml,text\/javascript,application\/javascript,text\/css,text\/plain,text\/json<span class=\"token punctuation\">&#034;<\/span><\/span><span class=\"token punctuation\">\/&gt;<\/span><\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815232022-689fc0b6e3465.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7136\u540e\u91cd\u542ftomcat<\/p>\n<h4>3.\u5f00\u542f\u538b\u7f29\u540e\u7684\u6548\u679c<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815232026-689fc0ba138d7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u56db.Nginx\u62a5Too many open files<\/h3>\n<p>Linux\u662f\u6709\u6587\u4ef6\u53e5\u67c4\u9650\u5236\u7684&#xff08;open files&#xff09;&#xff0c;\u4e00\u822c\u9ed8\u8ba4\u662f1024&#xff0c;\u5f53\u8d85\u8fc7\u8fd9\u4e2a\u6570\u91cf\u4fbf\u4f1a\u62a5 Too many open files\u9519\u8bef<\/p>\n<h4>1.\u67e5\u770b\u9ed8\u8ba4\u6587\u4ef6\u53e5\u67c4\u6570<\/h4>\n<p><span class=\"token builtin class-name\">ulimit<\/span> <span class=\"token parameter variable\">-a<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815232027-689fc0bb51bd1.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>2.\u589e\u5927\u5141\u8bb8\u6253\u5f00\u7684\u6587\u4ef6\u6570<\/h4>\n<p>\u6709\u4e24\u79cd\u4fee\u6539\u65b9\u5f0f&#xff1a;<\/p>\n<h5>2.1 \u547d\u4ee4\u884c\u65b9\u5f0f&#xff1a;<\/h5>\n<p><span class=\"token builtin class-name\">ulimit<\/span> <span class=\"token parameter variable\">-n<\/span> <span class=\"token number\">65535<\/span><\/p>\n<p>\u7acb\u5373\u751f\u6548&#xff0c;\u5bf9\u5f53\u524d\u7528\u6237\u6709\u6548&#xff0c;\u91cd\u542f\u540e\u5931\u6548<\/p>\n<h5>2.2 \u4fee\u6539\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6<\/h5>\n<p><span class=\"token function\">vim<\/span> \/etc\/security\/limits.conf<\/p>\n<p>\u5728\u6587\u4ef6\u6700\u540e\u52a0\u5165:<\/p>\n<p>* soft nofile 65535<br \/>\n* hard nofile 65535<\/p>\n<h4>3.\u4fee\u6539Nginx\u914d\u7f6e\u6587\u4ef6<\/h4>\n<p>worker_rlimit_nofile 65535;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815232027-689fc0bbe61ca.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>4.\u91cd\u542f nginx<\/h4>\n<p>nginx <span class=\"token parameter variable\">-s<\/span> reload<\/p>\n<h3>\u4e94.\u8bf7\u6c42\u94fe\u63a5\u540e\u7f00\u5e26 \/ \u548c\u4e0d\u5e26 \/\u7684\u533a\u522b<\/h3>\n<p>\u4ee5 http:\/\/localhost:8080\/test \u548c http:\/\/localhost:8080\/test\/ \u4e3a\u4f8b<\/p>\n<li>\n<p>\u5e26 \/ \u901a\u5e38\u8868\u793a\u8bbf\u95ee\u7684\u662f\u4e00\u4e2a\u76ee\u5f55\u3002\u5728 RESTful \u98ce\u683c\u7684 API \u4e2d&#xff0c;\u8fd9\u53ef\u80fd\u4ee3\u8868\u8be5\u76ee\u5f55\u4e0b\u7684\u8d44\u6e90\u96c6\u5408\u3002<br \/>\n\u4e0d\u5e26 \/ \u901a\u5e38\u8868\u793a\u8bbf\u95ee\u7684\u662f\u4e00\u4e2a\u5177\u4f53\u7684\u8d44\u6e90\u3002\u5b83\u53ef\u4ee5\u662f\u4e00\u4e2a\u6587\u4ef6\u6216\u4e00\u4e2a\u5355\u72ec\u7684\u8d44\u6e90\u5b9e\u4f53\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u540c\u7684\u670d\u52a1\u5668\u6216\u6846\u67b6&#xff08;\u5982 Flask\u3001Django\u3001FastAPI \u7b49&#xff09;\u4f1a\u6839\u636e URL \u7ed3\u5c3e\u7684 \/ \u5904\u7406\u65b9\u5f0f\u4e0d\u540c&#xff1a;<\/p>\n<\/li>\n<p>\u5982\u679c\u670d\u52a1\u5668\u4e25\u683c\u533a\u5206: \u8fd9\u79cd\u60c5\u51b5\u4e0b \/test \u548c \/test\/ \u4f1a\u88ab\u89c6\u4e3a\u5b8c\u5168\u4e0d\u540c\u7684\u4e24\u4e2a\u8def\u7531&#xff0c;\u5982\u679c\u6ca1\u6709\u5bf9\u5e94\u7684\u8def\u7531\u89c4\u5219&#xff0c;\u5c31\u76f4\u63a5\u8fd4\u56de 404\u3002<\/p>\n<p>\u5982\u679c\u670d\u52a1\u5668\u542f\u7528\u4e86\u81ea\u52a8\u91cd\u5b9a\u5411: \u670d\u52a1\u5668\u4f1a\u81ea\u52a8\u8fd4\u56de\u4e00\u4e2a 301 \u6216 308 \u91cd\u5b9a\u5411 \u5230\u6b63\u786e\u7684\u8def\u5f84\u3002<\/p>\n<h3>\u516d.\u9759\u6001\u6587\u4ef6\u65ad\u70b9\u7eed\u4f20<\/h3>\n<h4>1. \u6dfb\u52a0 nginx \u914d\u7f6e<\/h4>\n<p>   location \/download <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token builtin class-name\">alias<\/span> \/mnt\/file\/<span class=\"token punctuation\">;<\/span><br \/>\n        add_header Content-Disposition: <span class=\"token string\">&#039;attachment&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        add_header  Content-Type application\/octet-stream<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<h4>2.\u5c06\u53ef\u4e0b\u8f7d\u7684\u6587\u4ef6\u653e\u5728 \/mnt\/file\/ \u6587\u4ef6\u5939\u4e0b\u5373\u53ef<\/h4>\n<h4>3.\u8bf7\u6c42 http:\/ip:port\/download\/ &#043; &#034;\u6587\u4ef6\u540d\u79f0&#034;\u5373\u53ef<\/h4>\n<h3>\u4e03. linux\u4e0a springboot\u9879\u76ee\u63a5\u6536 header \u4e3a null<\/h3>\n<p>\u539f\u56e0:  \u53ef\u80fdheader\u4e2d\u5e26\u4e0b\u5212\u7ebf &#034;_ &#034; , \u7ecf\u8fc7 nginx \u8f6c\u53d1\u540e, \u4f1a\u8fc7\u6ee4\u6389\u8be5 header, \u5c06\u4e0b\u5212\u7ebf \u201c_\u201d \u6539\u4e3a &#034;-&#034;\u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf23\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Nginx\u7684\u5e38\u7528\u914d\u7f6e\uff0c\u5305\u62ec\u4e3b\u914d\u7f6e\u6587\u4ef6nginx.conf\u548c\u5b50\u914d\u7f6e\u6587\u4ef6default.conf\u7684\u8bbe\u7f6e\u3002\u4e3b\u914d\u7f6e\u6587\u4ef6\u5305\u542b\u5168\u5c40\u53c2\u6570\u5982worker\u8fdb\u7a0b\u6570\u3001CPU\u7ed1\u5b9a\u3001\u65e5\u5fd7\u683c\u5f0f\u3001Gzip\u538b\u7f29\u7b49\u4f18\u5316\u9009\u9879\u3002\u5b50\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b\u5c55\u793a\u4e86HTTPS\u670d\u52a1\u5668\u914d\u7f6e\uff0c\u5305\u62ecSSL\u8bc1\u4e66\u8bbe\u7f6e\u3001\u52a0\u5bc6\u5957\u4ef6\u9009\u62e9\u3001\u8d1f\u8f7d\u5747\u8861upstream\u5b9a\u4e49\uff0c\u4ee5\u53ca\u4e0d\u540clocation\u7684\u8def\u7531\u89c4\u5219\uff08\u9759\u6001\u6587\u4ef6\u670d\u52a1\u3001API\u4ee3\u7406\u3001\u8de8\u57df\u5904\u7406\u7b49\uff09\u3002\u91cd\u70b9\u914d\u7f6e\u9879\u5305\u62ec\uff1aworker\u8fdb\u7a0b\u4f18\u5316\u3001\u5b89\u5168\u5934\u8bbe\u7f6e\u3001SSL\/TLS\u5b89\u5168\u914d\u7f6e\u3001\u8bf7\u6c42\u5927\u5c0f\u9650\u5236\u3001\u8d1f\u8f7d\u5747\u8861\u5b9e\u73b0\u7b49\uff0c\u9002\u7528\u4e8e\u6784\u5efa\u9ad8\u6027\u80fd\u3001\u5b89\u5168\u7684W<\/p>\n","protected":false},"author":2,"featured_media":58254,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[117,43,44],"topic":[],"class_list":["post-58259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-nginx","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/58259.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf23\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Nginx\u7684\u5e38\u7528\u914d\u7f6e\uff0c\u5305\u62ec\u4e3b\u914d\u7f6e\u6587\u4ef6nginx.conf\u548c\u5b50\u914d\u7f6e\u6587\u4ef6default.conf\u7684\u8bbe\u7f6e\u3002\u4e3b\u914d\u7f6e\u6587\u4ef6\u5305\u542b\u5168\u5c40\u53c2\u6570\u5982worker\u8fdb\u7a0b\u6570\u3001CPU\u7ed1\u5b9a\u3001\u65e5\u5fd7\u683c\u5f0f\u3001Gzip\u538b\u7f29\u7b49\u4f18\u5316\u9009\u9879\u3002\u5b50\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b\u5c55\u793a\u4e86HTTPS\u670d\u52a1\u5668\u914d\u7f6e\uff0c\u5305\u62ecSSL\u8bc1\u4e66\u8bbe\u7f6e\u3001\u52a0\u5bc6\u5957\u4ef6\u9009\u62e9\u3001\u8d1f\u8f7d\u5747\u8861upstream\u5b9a\u4e49\uff0c\u4ee5\u53ca\u4e0d\u540clocation\u7684\u8def\u7531\u89c4\u5219\uff08\u9759\u6001\u6587\u4ef6\u670d\u52a1\u3001API\u4ee3\u7406\u3001\u8de8\u57df\u5904\u7406\u7b49\uff09\u3002\u91cd\u70b9\u914d\u7f6e\u9879\u5305\u62ec\uff1aworker\u8fdb\u7a0b\u4f18\u5316\u3001\u5b89\u5168\u5934\u8bbe\u7f6e\u3001SSL\/TLS\u5b89\u5168\u914d\u7f6e\u3001\u8bf7\u6c42\u5927\u5c0f\u9650\u5236\u3001\u8d1f\u8f7d\u5747\u8861\u5b9e\u73b0\u7b49\uff0c\u9002\u7528\u4e8e\u6784\u5efa\u9ad8\u6027\u80fd\u3001\u5b89\u5168\u7684W\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/58259.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-15T23:20:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815232018-689fc0b2b3572.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/58259.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/58259.html\",\"name\":\"Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-15T23:20:29+00:00\",\"dateModified\":\"2025-08-15T23:20:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/58259.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/58259.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/58259.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/58259.html","og_locale":"zh_CN","og_type":"article","og_title":"Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf23\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Nginx\u7684\u5e38\u7528\u914d\u7f6e\uff0c\u5305\u62ec\u4e3b\u914d\u7f6e\u6587\u4ef6nginx.conf\u548c\u5b50\u914d\u7f6e\u6587\u4ef6default.conf\u7684\u8bbe\u7f6e\u3002\u4e3b\u914d\u7f6e\u6587\u4ef6\u5305\u542b\u5168\u5c40\u53c2\u6570\u5982worker\u8fdb\u7a0b\u6570\u3001CPU\u7ed1\u5b9a\u3001\u65e5\u5fd7\u683c\u5f0f\u3001Gzip\u538b\u7f29\u7b49\u4f18\u5316\u9009\u9879\u3002\u5b50\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b\u5c55\u793a\u4e86HTTPS\u670d\u52a1\u5668\u914d\u7f6e\uff0c\u5305\u62ecSSL\u8bc1\u4e66\u8bbe\u7f6e\u3001\u52a0\u5bc6\u5957\u4ef6\u9009\u62e9\u3001\u8d1f\u8f7d\u5747\u8861upstream\u5b9a\u4e49\uff0c\u4ee5\u53ca\u4e0d\u540clocation\u7684\u8def\u7531\u89c4\u5219\uff08\u9759\u6001\u6587\u4ef6\u670d\u52a1\u3001API\u4ee3\u7406\u3001\u8de8\u57df\u5904\u7406\u7b49\uff09\u3002\u91cd\u70b9\u914d\u7f6e\u9879\u5305\u62ec\uff1aworker\u8fdb\u7a0b\u4f18\u5316\u3001\u5b89\u5168\u5934\u8bbe\u7f6e\u3001SSL\/TLS\u5b89\u5168\u914d\u7f6e\u3001\u8bf7\u6c42\u5927\u5c0f\u9650\u5236\u3001\u8d1f\u8f7d\u5747\u8861\u5b9e\u73b0\u7b49\uff0c\u9002\u7528\u4e8e\u6784\u5efa\u9ad8\u6027\u80fd\u3001\u5b89\u5168\u7684W","og_url":"https:\/\/www.wsisp.com\/helps\/58259.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-15T23:20:29+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250815232018-689fc0b2b3572.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/58259.html","url":"https:\/\/www.wsisp.com\/helps\/58259.html","name":"Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-15T23:20:29+00:00","dateModified":"2025-08-15T23:20:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/58259.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/58259.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/58259.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Nginx \u670d\u52a1\u5668\u5e38\u7528\u64cd\u4f5c"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/58259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=58259"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/58259\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/58254"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=58259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=58259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=58259"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=58259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}