{"id":1495,"date":"2022-01-05T16:36:50","date_gmt":"2022-01-05T08:36:50","guid":{"rendered":"http:\/\/diuut.com\/?p=1495"},"modified":"2022-08-30T19:29:33","modified_gmt":"2022-08-30T11:29:33","slug":"nginx%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%ef%bc%88nginx-conf%ef%bc%89%e9%85%8d%e7%bd%ae%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/diuut.com\/?p=1495","title":{"rendered":"Nginx\u914d\u7f6e\u6587\u4ef6\uff08nginx.conf\uff09\u914d\u7f6e\u8be6\u89e3"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\"><p>\u4ec5\u505a\u53c2\u8003<\/p><\/blockquote>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: yaml; title: ; notranslate\" title=\"\">\nuser  root;\n#Nginx\u7528\u6237\u53ca\u7ec4\uff1a\u7528\u6237 \u7ec4\u3002window\u4e0b\u4e0d\u6307\u5b9a\nworker_processes  1;\n#\u5de5\u4f5c\u8fdb\u7a0b\uff1a\u6570\u76ee\u3002\u6839\u636e\u786c\u4ef6\u8c03\u6574\uff0c\u901a\u5e38\u7b49\u4e8eCPU\u6570\u91cf\u6216\u80052\u500d\u4e8eCPU\u3002\n\nerror_log  logs\/error.log;\nerror_log  logs\/error.log  notice;\nerror_log  logs\/error.log  info;\n#\u9519\u8bef\u65e5\u5fd7\uff1a\u5b58\u653e\u8def\u5f84\u3002\n\npid        logs\/nginx.pid;\n#pid\uff08\u8fdb\u7a0b\u6807\u8bc6\u7b26\uff09\uff1a\u5b58\u653e\u8def\u5f84\u3002\n\n\nevents {\n    worker_connections  1024;\n    #\u6ca1\u4e2a\u5de5\u4f5c\u8fdb\u7a0b\u7684\u6700\u5927\u8fde\u63a5\u6570\u91cf\u3002\u6839\u636e\u786c\u4ef6\u8c03\u6574\uff0c\u548c\u524d\u9762\u5de5\u4f5c\u8fdb\u7a0b\u914d\u5408\u8d77\u6765\u7528\uff0c\u5c3d\u91cf\u5927\uff0c\u4f46\u662f\u522b\u628acpu\u8dd1\u5230100%\u5c31\u884c\u3002\n    #\u6bcf\u4e2a\u8fdb\u7a0b\u5141\u8bb8\u7684\u6700\u591a\u8fde\u63a5\u6570\uff0c\u7406\u8bba\u4e0a\u6bcf\u53f0nginx\u670d\u52a1\u5668\u7684\u6700\u5927\u8fde\u63a5\u6570\u4e3a\u3002worker_processes*worker_connections\n\n    open_file_cache_valid 80s;\n    #\u8fd9\u4e2a\u662f\u6307\u591a\u957f\u65f6\u95f4\u68c0\u67e5\u4e00\u6b21\u7f13\u5b58\u7684\u6709\u6548\u4fe1\u606f\u3002\n\n    keepalive_timeout 60;\n    #\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\u3002\n}\n\n\n#\u8bbe\u5b9ahttp\u670d\u52a1\u5668\uff0c\u5229\u7528\u5b83\u7684\u53cd\u5411\u4ee3\u7406\u529f\u80fd\u63d0\u4f9b\u8d1f\u8f7d\u5747\u8861\u652f\u6301\nhttp {\n    include       mime.types;\n    #\u8bbe\u5b9amime\u7c7b\u578b,\u7c7b\u578b\u7531mime.type\u6587\u4ef6\u5b9a\u4e49\n    default_type  application\/octet-stream;\n\t\tclient_max_body_size 20m; \n    #\u8fd9\u4e2a\u7c7b\u578b\u4f1a\u8ba9\u6d4f\u89c8\u5668\u8ba4\u4e3a\u54cd\u5e94\u662f\u666e\u901a\u7684\u6587\u4ef6\u6d41\uff0c\u5e76\u63d0\u793a\u7528\u6237\u4e0b\u8f7d\u6587\u4ef6\u3002\u53ef\u4ee5\u901a\u8fc7\u5728Nginx\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u505a\u5982\u4e0b\u914d\u7f6e\u8fbe\u5230\u8fd9\u6837\u7684\u76ee\u7684\u3002\n\n    sendfile        on;\n    #sendfile \u6307\u4ee4\u6307\u5b9a nginx \u662f\u5426\u8c03\u7528 sendfile \u51fd\u6570\uff08zero copy \u65b9\u5f0f\uff09\u6765\u8f93\u51fa\u6587\u4ef6\uff0c\n    #\u5bf9\u4e8e\u666e\u901a\u5e94\u7528\uff0c\u5fc5\u987b\u8bbe\u4e3a on,\n    #\u5982\u679c\u7528\u6765\u8fdb\u884c\u4e0b\u8f7d\u7b49\u5e94\u7528\u78c1\u76d8IO\u91cd\u8d1f\u8f7d\u5e94\u7528\uff0c\u53ef\u8bbe\u7f6e\u4e3a off\uff0c\n    #\u4ee5\u5e73\u8861\u78c1\u76d8\u4e0e\u7f51\u7edcI\/O\u5904\u7406\u901f\u5ea6\uff0c\u964d\u4f4e\u7cfb\u7edf\u7684uptime.\n\n\n    keepalive_timeout  65;\n    #\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\u3002\n\n    limit_conn_zone $server_name zone=mylimitzone:10m;\n    #\u6307\u4ee4\u63cf\u8ff0\u4f1a\u8bdd\u72b6\u6001\u5b58\u50a8\u533a\u57df\u3002\n    #\u4f1a\u8bdd\u7684\u6570\u76ee\u6309\u7167\u6307\u5b9a\u7684\u53d8\u91cf\u6765\u51b3\u5b9a\uff0c\u5b83\u4f9d\u8d56\u4e8e\u4f7f\u7528\u7684\u53d8\u91cf\u5927\u5c0f\u548cmemory_max_size\u7684\u503c\u3002\n    server_tokens off;  \n    #\u9690\u85cf\u7248\u672c\u53f7\u3002\n    \n\n    \t\n    rewrite_log on;\n    # \u5f00\u542f\u91cd\u5199\u65e5\u5fd7\n    log_format  main escape=json  \n    #\u65e5\u5fd7\u683c\u5f0f\u5b9a\u4e49\n    'remote_addr -$remote_addr : $remote_user $server_name &#91;$time_local] &quot;$request&quot; '\n    '$status $body_bytes_sent &quot;$request_body&quot; &quot;$http_referer&quot; '\n\t\t'&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot; '\n\t\t'&quot;Content-Type=$http_content_type&quot; &quot;heard_host0=$host&quot;  &quot;heard_host1=$http_host&quot;' '&quot;HTTP_X_FORWARDED_FOR=$HTTP_X_FORWARDED_FOR&quot;'\n\t\t'&quot;&quot;';\n\n    server {\n\t\t\t\tlisten       8096;\n\t\t\t\tserver_name  localhost;\n\n\t\t\t\tlocation \/ {\n\t\t\t\t\talias \/root\/syncFiles\/mbank\/app;\n\t\t\t\t\tlimit_conn mylimitzone 10;\n\t\t\t\t\tlimit_rate 1024k;\n\t      }     \n                   \n    }\n    \n\t\tserver {\n        listen       8097;\n        server_name  localhost;\n\t\t\t\t\n\t\tlocation \/ {\n\t  access_log logs\/mbankStatic.log main;\n          alias \/root\/syncFiles\/mbank\/app\/;\n          limit_conn mylimitzone 10;\n          limit_rate 1024k;\n      \t}   \n      \t\n\n\n\t  #\u624b\u673a\u7aef\u63a5\u53e3\u8c03\u7528\n\t\tlocation \/mbankAPI\/ {\n\t  #\u81ea\u5b9a\u4e49\u65e5\u5fd7\u6587\u4ef6\n\t  access_log logs\/mabankAPI.log main;\n          proxy_pass   http:\/\/172.17.54.47:8888\/;\n          index  index.html index.htm;\n\t\t\t\t}\n      \n    }\n    \n    server {\n        listen       8098;\n        server_name  localhost;\n\n        location \/ {\n          root   html;\n          index  index.html index.htm;\n        }\n\t\t\t\tlocation \/syncFiles {\n\t\t\t\t\talias \/root\/syncFiles;\n\t\t\t\t\tlimit_conn mylimitzone 10;\n\t\t\t\t\tlimit_rate 1024k;\n\t\t\t\t}  \t \n    }\n    \n    server {\n        listen       8099;\n        server_name  localhost;\n\n        #gzip\u914d\u7f6e\n        #\u5f00\u542fNginx Gzip\u538b\u7f29\n        gzip on;\n        #\u53ea\u6709\u8d85\u8fc7100k\u7684\u6587\u4ef6\u624d\u538b\u7f29\n        gzip_min_length 100k;\n        #image\/jpeg\u7c7b\u4f3c\u7684\u56fe\u7247\u6587\u4ef6\u672c\u8eab\u5c31\u5df2\u7ecf\u65f6\u7ecf\u8fc7\u538b\u7f29\u7684\u6587\u4ef6,gzip\u5bf9\u4e8e\u6587\u672c\u6587\u4ef6\u7684\u6548\u679c\u6781\u597d\n        gzip_types text\/plain application\/javascript text\/css application\/xml text\/javascript application\/x-httpd-php;\n        #\u4f4e\u7248\u672cIE\u7981\u7528Gzip\u538b\u7f29\n        gzip_disable &quot;MSIE&#91;1-6]\\.&quot;;\n        #\u538b\u7f29\u4f7f\u7528\u7684\u7f13\u5b58,\u6bcf\u4e2a\u5185\u5b58\u9875\u4e3a4k,\u7533\u8bf732\u500d\n        gzip_buffers 32 4k;\n        #\u8bbe\u7f6e\u538b\u7f29\u7ea7\u522b1-9,\u8d8a\u5927\u538b\u7f29\u6bd4\u4f8b\u8d8a\u9ad8,\u4f46\u6d6a\u8d39\u7684CPU\u8d44\u6e90\u4e5f\u8d8a\u591a,\u5efa\u8bae1-4\u5373\u53ef\n        gzip_comp_level 6;\n        gzip_vary on;\n        gzip_http_version 1.0;\n\n\n\t\t\t\tlocation \/eeeeeeee {            \n\t\t\t\t\talias \/home\/fffffffffffffff\/;            \n\t\t\t\t\tlimit_conn mylimitzone 10;     \n\t\t\t\t\tlimit_rate 1024k;        \n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tlocation \/aaaaaaa {            \n\t\t\t\t\t\talias \/root\/eeeeeeeeeeeee;            \n\t\t\t\t\t\tlimit_conn mylimitzone 10;        \n\t\t\t\t\t\tlimit_rate 1024k;        \n\t\t\t\t\t}\n    }\n    \n}\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u4ec5\u505a\u53c2\u8003<\/p>\n","protected":false},"author":1,"featured_media":1501,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[48],"_links":{"self":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1495"}],"collection":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1495"}],"version-history":[{"count":4,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1495\/revisions"}],"predecessor-version":[{"id":1589,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1495\/revisions\/1589"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/media\/1501"}],"wp:attachment":[{"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}