{"id":32950,"date":"2023-10-28T10:24:02","date_gmt":"2023-10-20T22:15:48","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/"},"modified":"2024-05-04T06:24:21","modified_gmt":"2024-05-03T22:24:21","slug":"nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/","title":{"rendered":"Nginx\u914d\u7f6e\u6458\u8981"},"content":{"rendered":"<h2>\u9996\u5148<\/h2>\n<p>\u6211\u53ea\u662f\u76f2\u76ee\u5730\u4f7f\u7528nginx\u6765\u542f\u52a8unicorn\uff0c\u51e0\u4e4e\u4e0d\u4e86\u89e3\u914d\u7f6e\u6587\u4ef6\u7684\u5185\u5bb9\u3002<br \/>\n\u6240\u4ee5\u6211\u60f3\u5728\u8fd9\u91cc\u603b\u7ed3nginx\u7684\u914d\u7f6e\u5185\u5bb9\uff0c\u4ee5\u4fbf\u81ea\u5df1\u8bb0\u4f4f\u3002<\/p>\n<p>\u6211\u5df2\u7ecf\u8bb0\u5f55\u4e86\u901a\u5e38\u4f1a\u4f7f\u7528\u7684\u5927\u591a\u6570\u8bbe\u7f6e\u3002<\/p>\n<p>\u56e0\u4e3a\u8bb0\u5f55\u7684\u5185\u5bb9\u5305\u542b\u4e86\u5b9e\u9645\u5c1d\u8bd5\u8fc7\u548c\u672a\u5c1d\u8bd5\u8fc7\u7684\u9879\u76ee\uff0c\u6240\u4ee5\u53ef\u80fd\u5b58\u5728\u9519\u8bef\u7684\u8bbe\u7f6e\u7b49\u60c5\u51b5\u3002\u5982\u679c\u60a8\u80fd\u5728\u8bc4\u8bba\u4e2d\u63d0\u9192\u6211\u76f8\u5173\u95ee\u9898\uff0c\u6211\u5c06\u4e0d\u80dc\u611f\u6fc0\u3002<\/p>\n<h2>\u5b89\u88c5<\/h2>\n<p>\u6211\u8ba4\u4e3a\u60a8\u6700\u597d\u770b\u5176\u4ed6\u4eba\u7684\u6587\u7ae0\u6765\u4e86\u89e3\u5b89\u88c5\u7684\u65b9\u6cd5\uff0c\u800c\u4e0d\u662f\u6211\u6765\u5199\u3002<br \/>\n\u5982\u679c\u8981\u5728CentOS\u4e0a\u8fdb\u884c\u5b89\u88c5\uff0c\u4ee5\u4e0b\u7684\u6587\u7ae0\u53ef\u80fd\u4f1a\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">CentOS6.x\u306b\u3066nginx\u306e\u6700\u65b0\u7248\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u624b\u9806<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">CentOS 6.5\u3067nginx\u3092\u52d5\u304b\u3059\u70ba\u306e\u6700\u4f4e\u9650\u306e\u8a2d\u5b9a<\/ul>\n<p>\u5982\u679c\u60a8\u6253\u7b97\u4f7f\u7528chef\u8fdb\u884c\u5b89\u88c5\uff0c\u4ee5\u4e0b\u7684\u6587\u7ae0\u53ef\u80fd\u4f1a\u5bf9\u60a8\u6709\u5e2e\u52a9\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Chef\u3067nginx\u3092\u5c0e\u5165\u3057\u3066\u307f\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Chef\u3067Nginx\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u304d\u306b\u30cf\u30de\u3063\u305f<\/ul>\n<p>\u5982\u679c\u60a8\u80fd\u53c2\u8003\u6211\u7684\u6587\u7ae0\u6765\u4e86\u89e3\u6709\u5173\u53a8\u5e08\u7684\u7528\u6cd5\uff0c\u6211\u5c06\u975e\u5e38\u611f\u6fc0\u3002<\/p>\n<h3>\u6307\u4ee4<\/h3>\n<p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u3002<\/p>\n<pre class=\"post-pre\"><code>$ \/etc\/init.d\/nginx -h\r\nUsage: nginx {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}\r\n<\/code><\/pre>\n<h4>\u5f00\u59cb\u8fd0\u884c<\/h4>\n<p>\u66ab\u6642\u53ea\u5beb\u4e0b\u555f\u52d5\u6307\u4ee4\u3002<\/p>\n<pre class=\"post-pre\"><code>$ \/etc\/init.d\/nginx start\r\n# \u3082\u3057\u304f\u306f\r\n$ service nginx start\r\n<\/code><\/pre>\n<h2>\u914d\u7f6e\u6587\u4ef6<\/h2>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0cnginx\u7684\u914d\u7f6e\u6587\u4ef6\u88ab\u653e\u7f6e\u5728\/etc\/nginx\/nginx.conf\u4e2d\u3002<br \/>\n\u8fd9\u6b21\u6211\u4eec\u628a\u53ef\u4ee5\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u5185\u5bb9\u603b\u7ed3\u4e00\u4e0b\uff08\u505a\u4e2a\u8bb0\u5f55\uff09\u3002<\/p>\n<h3>\u7528\u6237<\/h3>\n<pre class=\"post-pre\"><code>user nginx;\r\n<\/code><\/pre>\n<p>\u542f\u52a8nginx\u65f6\uff0c\u5c06\u542f\u52a8\u4e09\u4e2a\u8fdb\u7a0b\uff1a\u4e3b\u8fdb\u7a0b\u3001\u5de5\u4f5c\u8fdb\u7a0b\u548c\u7f13\u5b58\u7ba1\u7406\u8fdb\u7a0b\u3002<br \/>\n\u8981\u6307\u5b9a\u542f\u52a8\u9664\u4e3b\u8fdb\u7a0b\u4e4b\u5916\u7684\u8fdb\u7a0b\u7684\u7528\u6237\u3002<br \/>\n\u4e3b\u8fdb\u7a0b\u5c06\u7531root\u7528\u6237\u542f\u52a8\u3002<\/p>\n<h3>\u5de5\u4f5c\u8fdb\u7a0b<\/h3>\n<pre class=\"post-pre\"><code>worker_processes auto\r\nworker_processes 2\r\n<\/code><\/pre>\n<p>\u4e3a\u4e86\u9002\u5e94 Nginx \u7684\u5355\u7ebf\u7a0b\u8fd0\u884c\u6a21\u5f0f\uff0c\u5e94\u8be5\u6839\u636e\u6838\u5fc3\u6570\u8fdb\u884c\u8bbe\u7f6e\u3002<br \/>\n\u4f3c\u4e4e\u6ca1\u6709\u95ee\u9898\uff0c\u5373\u4f7f\u6307\u5b9a\u7684\u503c\u8d85\u8fc7\u4e86\u6838\u5fc3\u6570\u3002<br \/>\n\u5982\u679c\u6307\u5b9a\u4e3a &#8220;auto&#8221;\uff0c\u5219\u4f1a\u81ea\u52a8\u8bbe\u7f6e\u6838\u5fc3\u6570\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770bCPU\u6838\u5fc3\u6570\u91cf\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">grep <\/span>processor \/proc\/cpuinfo |wc\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8981\u660e\u786e\u5730\u4f7f\u7528CPU\u5206\u914d\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u9009\u9879\u3002<\/p>\n<pre class=\"post-pre\"><code>worker_cpu_affinity 01 11\r\n<\/code><\/pre>\n<p>\u53c2\u8003\u94fe\u63a5\uff1a<br \/>\nNginx\u7684worker_processes\u548cworker_cpu_affinity<\/p>\n<h3>\u5de5\u4f5c\u8fdb\u7a0b\u6587\u4ef6\u6253\u5f00\u9650\u5236\u6570<\/h3>\n<pre class=\"post-pre\"><code>worker_rlimit_nofile  4096;\r\n<\/code><\/pre>\n<p>\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u4e0a\u9650\u6570\u91cf\u3002<br \/>\n\u5927\u7ea6\u662f\u540e\u9762\u63d0\u5230\u7684worker_connections\u76843\u52304\u500d\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u786e\u8ba4\u7cfb\u7edf\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nv\">$ <\/span><span class=\"nb\">cat<\/span> \/proc\/sys\/fs\/file-max\r\n<\/code><\/pre>\n<p>\u5728nginx\u4e2d\u5904\u7406\u201c\u6253\u5f00\u6587\u4ef6\u8fc7\u591a\u201d\u9519\u8bef\u7684\u65b9\u6cd5\uff0c\u8bf7\u53c2\u8003\u4ee5\u4e0b\u7f51\u5740\uff1a<\/p>\n<h3>\u9519\u8bef\u65e5\u5fd7<\/h3>\n<pre class=\"post-pre\"><code>error_log \/var\/log\/nginx\/error.log;\r\n<\/code><\/pre>\n<p>\u6211\u8ba4\u4e3a\u9ed8\u8ba4\u8bbe\u7f6e\u5e94\u8be5\u662f\u53ef\u4ee5\u7684\uff0c\u5f53Nginx\u8fd0\u884c\u4f46\u4f3c\u4e4e\u65e0\u6cd5\u5230\u8fbeRails\u65f6\uff0c\u8fd9\u662f\u6211\u4eec\u9996\u5148\u67e5\u770b\u7684\u65e5\u5fd7\u4f4d\u7f6ew\uff08\u6216\u8bbf\u95ee\u65e5\u5fd7\u3002\u7a0d\u540e\u63d0\u5230\uff09\u3002<\/p>\n<p>\u8fd9\u4e2a\u5b9a\u4e49\u53ef\u4ee5\u5728http\u6216\u8005server\u5757\u4e2d\u4f7f\u7528\u3002<\/p>\n<h3>\u8fdb\u7a0b\u6807\u8bc6\u7b26<\/h3>\n<pre class=\"post-pre\"><code>pid \/var\/run\/nginx.pid;\r\n<\/code><\/pre>\n<p>\u6211\u4e0d\u5e38\u67e5\u770b\u8fd9\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u4f46\u662f\u5176\u4e2d\u5b58\u50a8\u4e86PID\u3002<br \/>\n\u6211\u4e0d\u77e5\u4e0d\u89c9\u4f1a\u7528\u4ee5\u4e0b\u547d\u4ee4\u786e\u8ba4\u4e00\u4e0b&#8230;\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ps aux | grep nginx\r\nroot     31866  0.0  0.0  65724   276 ?        Ss   09:55   0:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\r\nnginx    31868  0.0  0.2  67040  1544 ?        S    09:55   0:00 nginx: worker process                   \r\nnginx    31869  0.0  0.0  65944   336 ?        S    09:55   0:00 nginx: cache manager process\r\n<\/code><\/pre>\n<h2>\u4e8b\u4ef6\u6a21\u5757<\/h2>\n<pre class=\"post-pre\"><code>events {\r\n    ...\r\n}\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u5b9a\u4e49event\u6a21\u5757\u3002<br \/>\n\u4ee5\u4e0b\u4e09\u9879\u53ef\u4ee5\u5728&#8230;\u4e2d\u63d0\u53ca\u3002<\/p>\n<h3>\u5de5\u4f5c\u7ebf\u7a0b\u8fde\u63a5\u6570<\/h3>\n<pre class=\"post-pre\"><code>worker_connections 512;\r\n<\/code><\/pre>\n<p>\u8fd9\u662f\u4e00\u4e2a\u5de5\u4eba\u53ef\u4ee5\u540c\u65f6\u5904\u7406\u7684\u8fde\u63a5\u6570\u3002<\/p>\n<h3>\u591a\u6b21\u63a5\u53d7<\/h3>\n<pre class=\"post-pre\"><code>multi_accept on;\r\n<\/code><\/pre>\n<p>\u5bf9\u4e8eon\u7684\u60c5\u51b5\uff0c\u540c\u65f6\u63a5\u53d7\u591a\u4e2a\u8fde\u63a5\u3002<\/p>\n<h3>\u4f7f\u7528<\/h3>\n<pre class=\"post-pre\"><code>use epoll\r\n<\/code><\/pre>\n<p>\u5982\u679c\u662fLinux\u5185\u68382.6\u4ee5\u4e0a\u7684\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528epoll\uff1b\u5982\u679c\u662fBSD\u7cfb\u7edf\uff0c\u5219\u4f7f\u7528kqueue\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6211\u8ba4\u4e3a\u4ee5\u4e0a\u8bbe\u7f6e\u6ca1\u6709\u95ee\u9898\u3002<\/p>\n<h2>\u4f7f\u7528HTTP\u5c4f\u853d<\/h2>\n<pre class=\"post-pre\"><code>http {\r\n    ...\r\n}\r\n<\/code><\/pre>\n<p>\u4e3b\u8981\u5904\u7406\u4f5c\u4e3aWeb\u670d\u52a1\u5668\u4f7f\u7528\u7684\u529f\u80fd\u3002<\/p>\n<h3>\u670d\u52a1\u5668\u4ee4\u724c<\/h3>\n<pre class=\"post-pre\"><code>server_tokens off;\r\n<\/code><\/pre>\n<p>\u5728\u9519\u8bef\u9875\u9762\u7684\u9875\u811a\u4e0a\u663e\u793a Nginx \u7684\u7248\u672c\u7684\u8bbe\u7f6e\u3002<br \/>\n\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0c\u5173\u95ed\u662f\u66f4\u597d\u7684\u9009\u62e9\u3002<\/p>\n<h3>\u5305\u62ec\/etc\/nginx\/mime.types;<\/h3>\n<pre class=\"post-pre\"><code>include       \/etc\/nginx\/mime.types;\r\n<\/code><\/pre>\n<p>\u8bfb\u53d6\u5b9a\u4e49\u4e86 MIME \u7c7b\u578b\u548c\u6587\u4ef6\u6269\u5c55\u540d\u5173\u8054\u7684\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>types {\r\n    text\/html                             html htm shtml;\r\n    text\/css                              css;\r\n    text\/xml                              xml;\r\n    image\/gif                             gif;\r\n    image\/jpeg                            jpeg jpg;\r\n    application\/javascript                js;\r\n    ...\r\n}\r\n<\/code><\/pre>\n<p>\u8fd9\u6837\u7684\u5f62\u5f0f\u4e0b\uff0c MIME \u7c7b\u578b\u88ab\u6574\u7406\u5728\u4e00\u8d77\u3002<\/p>\n<h3>\u9ed8\u8ba4\u7c7b\u578b<\/h3>\n<pre class=\"post-pre\"><code>default_type  application\/octet-stream;\r\n<\/code><\/pre>\n<p>\u5f53\u5728\u4e0a\u8ff0\u7684mime.types\u6587\u4ef6\u4e2d\u65e0\u6cd5\u6839\u636e\u6587\u4ef6\u6269\u5c55\u540d\u786e\u5b9aMIME\u7c7b\u578b\u65f6\uff0c\u5c06\u5e94\u7528\u5728\u6b64\u5904\u6307\u5b9a\u7684MIME\u7c7b\u578b\u3002<br \/>\n\u9ed8\u8ba4\u8bbe\u7f6e\u4e3atext\/plain\u3002<\/p>\n<h3>\u65e5\u5fd7\u683c\u5f0f<\/h3>\n<pre class=\"post-pre\"><code>log_format main 'time:$time_iso8601\\t'...\r\nlog_format ltsv 'time:$time_iso8601\\t'...\r\n<\/code><\/pre>\n<p>\u5b9a\u4e49\u65e5\u5fd7\u7684\u683c\u5f0f\u3002\u53ef\u4ee5\u9009\u62e9\u4e3b\u8981\u7684(main)\u6216ltsv\u7b49\uff0c\u5e76\u5b9a\u4e49\u8981\u8f93\u51fa\u7684\u503c\u3002<br \/>\n\u53ef\u4ee5\u4f7f\u7528\u5728\u8fd9\u91cc\u5b9a\u4e49\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0bURL\u94fe\u63a5\uff1a<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx\u306e\u30ed\u30b0\u3092LTSV\u5f62\u5f0f\u3067\u51fa\u529b\u3057\u3066\u3001fluentd\u7d4c\u7531\u3067MongoDB\u306b\u4fdd\u5b58\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">LTSV FAQ &#8211; LTSV \u3063\u3066\u4f55? \u3069\u3046\u3044\u3046\u3068\u3053\u308d\u304c\u826f\u3044\u306e?<\/ul>\n<h3>\u8bbf\u95ee\u65e5\u5fd7<\/h3>\n<pre class=\"post-pre\"><code>access_log \/var\/log\/nginx\/access.log ltsv;\r\n<\/code><\/pre>\n<p>\u5728\u4e0a\u8ff0\u63d0\u53ca\u7684log_format\u4e4b\u540e\uff0c\u8fdb\u884c\u6700\u540e\u4e00\u9879\u6307\u5b9a\u3002<\/p>\n<p>\u8fd9\u4e2a\u5b9a\u4e49\u53ef\u4ee5\u5728\u670d\u52a1\u5668\u5757\u7b49\u5730\u65b9\u4f7f\u7528\u3002<\/p>\n<pre class=\"post-pre\"><code>access_log off;\r\n<\/code><\/pre>\n<p>\u8fd8\u53ef\u4ee5\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<h3>\u5b57\u7b26\u96c6<\/h3>\n<pre class=\"post-pre\"><code>charset UTF-8;\r\n<\/code><\/pre>\n<p>\u5728\u54cd\u5e94\u5934\u4e2d\u6dfb\u52a0\u7c7b\u4f3c\u4e8eContent-Type: text\/html; charset=UTF-8\u7684\u5b57\u7b26\u96c6\u3002<\/p>\n<h3>\u53d1\u9001\u6587\u4ef6<\/h3>\n<pre class=\"post-pre\"><code>sendfile on;\r\n<\/code><\/pre>\n<p>\u6307\u5b9a\u662f\u5426\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u7684sendfile\u529f\u80fd\u3002\u4f7f\u7528sendfile\u53ef\u4ee5\u5728nginx\u5185\u90e8\u6587\u4ef6\u8bfb\u53d6\u548c\u53d1\u9001\u7684\u8fc7\u7a0b\u4e2d\u907f\u514d\u8fdb\u884c\uff0c\u800c\u662f\u5728\u5185\u6838\u7a7a\u95f4\u5185\u5b8c\u6210\uff0c\u8fd9\u6837\u53ef\u4ee5\u9ad8\u6548\u5730\u53d1\u9001\u6587\u4ef6\u3002\uff08\u7528\u4e8e\u4f20\u8f93js\u6587\u4ef6\u548ccss\u6587\u4ef6\uff1f\uff09<br \/>\n\u9ed8\u8ba4\u8bbe\u5b9a\u503c\u4e3aoff\u3002<\/p>\n<h3>tcp_nopush \u6307\u4ee4<\/h3>\n<pre class=\"post-pre\"><code>tcp_nopush on;\r\n<\/code><\/pre>\n<p>\u5f53sendfile\u8bbe\u7f6e\u4e3aon\u65f6\uff0c\u5c06\u6b64\u914d\u7f6e\u8bbe\u7f6e\u4e3aon\uff0c\u54cd\u5e94\u5934\u548c\u6587\u4ef6\u5185\u5bb9\u5c06\u4e00\u8d77\u53d1\u9001\u3002\u8fd9\u6837\u53ef\u4ee5\u4ee5\u8f83\u5c11\u7684\u6570\u636e\u5305\u6570\u91cf\u9ad8\u6548\u5730\u53d1\u9001\u3002<\/p>\n<h3>\u5173\u95edTCP\u5ef6\u8fdf<\/h3>\n<pre class=\"post-pre\"><code>tcp_nodelay on;\r\n<\/code><\/pre>\n<p>\u8fd9\u662f\u4e00\u79cd\u9009\u9879\uff0c\u53ef\u4ee5\u76f4\u63a5\u53d1\u9001\u5c0f\u6570\u636e\u5305\uff0c\u65e0\u9700\u7b49\u5f85\u3002\u56e0\u4e3a\u6ca1\u6709\u7b49\u5f85\u65f6\u95f4\uff0c\u6240\u4ee5\u901f\u5ea6\u66f4\u5feb\uff0c\u4f46\u53d1\u9001\u7684\u6570\u636e\u5305\u6570\u91cf\u548c\u5927\u5c0f\u4f1a\u589e\u52a0\u3002<br \/>\n\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u662f\u6253\u5f00\u7684\u3002<br \/>\n\u636e\u8bf4\u5b83\u7684\u4f5c\u7528\u4e0etcp_nopush\u76f8\u53cd\uff0c\u4f46nginx\u5df2\u7ecf\u88ab\u5b9e\u73b0\u6210\u80fd\u591f\u540c\u65f6\u8fd0\u884c\u8fd9\u4e24\u4e2a\u9009\u9879\u3002<\/p>\n<p>\u5982\u679c\u7a0b\u5e8f\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\uff0c\u5c1d\u8bd5\u5c06sendfile\u3001tcp_nopush\u548ctcp_nodelay\u5168\u90e8\u5173\u95ed\uff0c\u6709\u65f6\u53ef\u4ee5\u8ba9\u5b83\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<h3>\u4fdd\u6301\u6d3b\u52a8\u65f6\u95f4\u3002<\/h3>\n<pre class=\"post-pre\"><code>keepalive_timeout 75;\r\n<\/code><\/pre>\n<p>\u8fd9\u662fHTTP\u7684\u6301\u7eed\u8fde\u63a5\u65f6\u95f4\u3002\u5982\u679c\u8bbe\u7f6e\u5f97\u592a\u957f\uff0c\u5c06\u4f1a\u589e\u52a0\u7ebf\u7a0b\u5728\u4fdd\u6301\u8fde\u63a5\u4e0a\u7684\u8d1f\u8f7d\u3002<br \/>\n\u5c06\u5176\u8bbe\u4e3a0\u5373\u4e3a\u5173\u95ed\u3002<br \/>\n\u9ed8\u8ba4\u4e3a75\u3002<\/p>\n<h3>\u4fdd\u6301\u6d3b\u52a8\u8bf7\u6c42<\/h3>\n<pre class=\"post-pre\"><code>keepalive_requests 100;\r\n<\/code><\/pre>\n<p>\u5f53keepalive_timeout\u5904\u4e8e\u6709\u6548\u72b6\u6001\u65f6\uff0c\u5982\u679c\u6765\u81ea\u540c\u4e00\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u8fbe\u5230\u6307\u5b9a\u6570\u91cf\uff0c\u5c06\u4f1a\u65ad\u5f00\u8fde\u63a5\u3002\u5982\u679c\u6b63\u5e38\u4f7f\u7528\uff0c\u6211\u89c9\u5f97keepalive_timeout\u8bbe\u7f6e\u4e3a5\uff0ckeepalive_requests\u8bbe\u7f6e\u4e3a20\u5e94\u8be5\u8db3\u591f\u3002\u9ed8\u8ba4\u503c\u4e3a100\u3002<\/p>\n<h3>set_real_ip_from\u548creal_ip_header<\/h3>\n<pre class=\"post-pre\"><code>set_real_ip_from   10.0.0.0\/8;\r\nreal_ip_header     X-Forwarded-For;\r\n<\/code><\/pre>\n<p>\u4e3a\u4e86\u9632\u6b62\u5728\u7ecf\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u6216\u8d1f\u8f7d\u5747\u8861\u5668\u65f6\u4e22\u5931\u539f\u59cbIP\u5730\u5740\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528set_real_ip_from\u6307\u5b9a\u4ee3\u7406\u670d\u52a1\u5668\u6216\u8d1f\u8f7d\u5747\u8861\u5668\uff0c\u5e76\u5728real_ip_header\u4e2d\u6307\u5b9a\u5305\u542b\u6b63\u786eIP\u5730\u5740\u7684\u5934\u90e8\u53c2\u6570\u3002\u901a\u5e38\u4f7f\u7528X-Forwarded-For\uff0c\u4f46\u7531\u4e8e\u4f9d\u8d56\u4e0a\u5c42\u670d\u52a1\u5668\uff0c\u5982\u679c\u65e0\u6cd5\u6b63\u786e\u83b7\u53d6IP\u5730\u5740\uff0c\u8bf7\u786e\u8ba4\u5176\u4ed6\u65b9\u6cd5\u3002<\/p>\n<p>set_real_ip_from\u53ef\u4ee5\u5199\u591a\u4e2a\u3002<\/p>\n<h3>\u5ba2\u6237\u7aef\u8bf7\u6c42\u5934\u8d85\u65f6\u548c\u5ba2\u6237\u7aef\u8bf7\u6c42\u4f53\u8d85\u65f6<\/h3>\n<pre class=\"post-pre\"><code>client_header_timeout 10;\r\nclient_body_timeout 10;\r\n<\/code><\/pre>\n<p>\u5ba2\u6237\u7aef\u8bf7\u6c42\u5934\u548c\u5ba2\u6237\u7aef\u8bf7\u6c42\u4f53\u7684\u8bfb\u53d6\u8d85\u65f6\u65f6\u95f4\u3002<\/p>\n<h3>\u5ba2\u6237\u7aef\u8bf7\u6c42\u4f53\u7f13\u51b2\u533a\u5927\u5c0f\uff08client_body_buffer_size\uff09\u548c\u5ba2\u6237\u7aef\u8bf7\u6c42\u4f53\u4e34\u65f6\u8def\u5f84\uff08client_body_temp_path\uff09\u3002<\/h3>\n<pre class=\"post-pre\"><code>client_body_buffer_size      32k;\r\nclient_body_temp_path \/dev\/shm\/client_body_temp 1 2;\r\n<\/code><\/pre>\n<p>\u63a5\u6536\u5230\u7684\u8bf7\u6c42\u4f53\u5c06\u5728\u5185\u5b58\u4e2d\u4fdd\u6301\uff0c\u76f4\u5230\u8fbe\u5230client_body_buffer_size\u7684\u5927\u5c0f\uff0c\u8d85\u8fc7\u8fd9\u4e2a\u5927\u5c0f\u5219\u4f1a\u4ee5\u6587\u4ef6\u7684\u5f62\u5f0f\u5199\u5165\u5230client_body_temp_path\u4e2d\u3002<\/p>\n<p>\u5728nginx\u4e2d\uff0c\u8fd9\u7bc7\u6587\u7ae0\u8ba8\u8bba\u4e86\u4e0e\u8bf7\u6c42\u4f53\u7f13\u51b2\u6709\u5173\u7684\u95ee\u9898\u4ee5\u53ca\u6539\u8fdb\u63aa\u65bd\u3002\u5c3d\u7ba1\u5b9a\u4e49\u4e86client_body_buffer_size\uff0c\u4f46\u53ea\u8981\u5728server\u5757\u4e2d\u6307\u5b9aproxy_request_buffering off\uff0c\u5c31\u80fd\u907f\u514d\u5728\u8be5\u6761\u4ef6\u4e0b\u8fdb\u884c\u7f13\u51b2\u3002<\/p>\n<pre class=\"post-pre\"><code>server {\r\n    listen 80;\r\n    server_name example.com;\r\n\r\n    location \/upload {\r\n        proxy_request_buffering off;\r\n        proxy_pass http:\/\/upload_backend;\r\n    }\r\n}\r\n<\/code><\/pre>\n<h3>\u5ba2\u6237\u7aef\u6700\u5927\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f<\/h3>\n<pre class=\"post-pre\"><code>client_max_body_size 1m;\r\n<\/code><\/pre>\n<p>\u8fd9\u662f\u4ece\u5ba2\u6237\u7aef\u53d1\u9001\u7684\u8bf7\u6c42\u4e3b\u4f53\u7684\u6700\u5927\u503c\u3002\u5982\u679c\u53d1\u9001\u7684\u5927\u5c0f\u8d85\u8fc7\u6b64\u9650\u5236\uff0c\u5c06\u4f1a\u51fa\u73b0413\uff08\u8bf7\u6c42\u5b9e\u4f53\u8fc7\u5927\uff09\u9519\u8bef\u3002<\/p>\n<h3>\u5ba2\u6237\u7aef\u5934\u7f13\u51b2\u533a\u5927\u5c0f\u548c\u5927\u5ba2\u6237\u7aef\u5934\u7f13\u51b2\u533a<\/h3>\n<pre class=\"post-pre\"><code>client_header_buffer_size 1k;\r\nlarge_client_header_buffers 4 8k;\r\n<\/code><\/pre>\n<p>\u4e00\u822c\u60c5\u51b5\u4e0b\u4e0d\u7528\u62c5\u5fc3\uff0c\u8fd9\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\u3002<br \/>\n\u5982\u679c\u6536\u5230\u8d85\u51fa\u6b64\u5b9a\u4e49\u7684\u6807\u5934\uff0c\u5219\u4f1a\u53d1\u751f414\uff08\u8bf7\u6c42URI\u8fc7\u957f\uff09\u9519\u8bef\u3002<\/p>\n<h3>limit_conn\u9650\u5236\u5e76\u53d1\u8fde\u63a5\u6570\u7684\u6a21\u5757\uff0climit_conn_zone\u7528\u4e8e\u5b9a\u4e49\u8fde\u63a5\u72b6\u6001\u5b58\u50a8\u7684\u5171\u4eab\u5185\u5b58\u533a\u57df\u3002<\/h3>\n<pre class=\"post-pre\"><code>limit_conn_zone $binary_remote_addr zone=addr:10m;\r\nlimit_conn  addr  100;\r\n<\/code><\/pre>\n<p>\u5982\u679c\u60a8\u60f3\u9650\u5236\u540c\u65f6\u8fde\u63a5\u6570\u4ee5\u9632\u6b62DoS\u653b\u51fb\u7b49\uff0c\u8bf7\u53c2\u8003\u4ee5\u4e0b\u7f51\u7ad9\u3002<\/p>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0b\u7f51\u5740\uff0c\u5176\u4e2d\u5217\u51fa\u4e86\u53ef\u5728Nginx\u4e2d\u4f7f\u7528\u7684\u9650\u5236\u5217\u8868\u3002<\/p>\n<h3>\u4ee3\u7406\u76f8\u5173<\/h3>\n<pre class=\"post-pre\"><code>proxy_buffering on;\r\nproxy_buffer_size     8k;\r\nproxy_buffers         100 8k;\r\nproxy_cache_path \/var\/lib\/nginx\/cache levels=1:2 keys_zone=CACHE:512m inactive=1d  max_size=60g;\r\n<\/code><\/pre>\n<p>\u8fd9\u662f\u5173\u4e8e\u914d\u7f6e\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u7684\u53cd\u5411\u4ee3\u7406\u7684\u8bbe\u7f6e\u3002<br \/>\n\u8fd9\u4e2a\u5730\u65b9\u8d85\u51fa\u4e86\u6211\u7684\u7406\u89e3&#8230;&#8230;\uff08\u5982\u679c\u4f7f\u7528unicorn\u7684\u8bdd\uff0c\u6211\u89c9\u5f97\u9700\u8981\u4ed4\u7ec6\u8bbe\u7f6e\u8fd9\u91cc\u7684\u914d\u7f6e&#8230;&#8230;\uff09\u3002<br \/>\n\u5c1d\u8bd5\u4f7f\u7528Nginx\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\uff08\u7f13\u5b58\uff09\u53ef\u80fd\u4f1a\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<h3>gzip\u76f8\u5173<\/h3>\n<pre class=\"post-pre\"><code>gzip on;\r\ngzip_http_version 1.0;\r\ngzip_comp_level 2;\r\ngzip_proxied expired no-cache no-store private auth;\r\ngzip_vary off;\r\ngzip_types text\/plain\r\n       text\/css\r\n       text\/xml\r\n       ...\r\n       application\/json;\r\ngzip_min_length 1000;\r\ngzip_disable \"MSIE [1-6]\\.\";\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8981\u4f7f\u7528gzip\u5bf9\u54cd\u5e94\u8fdb\u884c\u538b\u7f29\uff0c\u8bf7\u6253\u5f00\u5b83\u3002\u8fd9\u6837\u53ef\u4ee5\u51cf\u5c11\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u4f20\u8f93\u91cf\u3002<\/p>\n<p>\u53ea\u9700\u7b80\u5355\u5730\u8bb0\u5f55\u5728\u5b9e\u9645\u4f7f\u7528\u65f6\u9700\u8981\u66f4\u6539\u7684\u90e8\u5206\u3002<br \/>\n\u4ec5\u6307\u5b9a\u5728gzip_types\u4e2d\u6307\u5b9a\u7684\u6587\u4ef6\u7c7b\u578b\u624d\u6709\u6548\u3002<br \/>\n\u4ec5\u5bf9\u6307\u5b9a\u5728gzip_proxied\u4e2d\u7684\u8bf7\u6c42\u7c7b\u578b\u6709\u6548\u3002<br \/>\n\u54cd\u5e94\u957f\u5ea6\u4f4e\u4e8egzip_min_length\u5c06\u4e0d\u4f1a\u88ab\u538b\u7f29\u3002\u538b\u7f29\u6210\u672c\u4f1a\u53d8\u5f97\u5f88\u9ad8\u3002<br \/>\ngzip_disable\uff0c\u6682\u65f6\u5c06IE6\u53ca\u4ee5\u4e0b\u7248\u672c\u8bbe\u4e3a\u4e0d\u9002\u7528gzip\u3002<\/p>\n<h3>\u6253\u5f00\u6587\u4ef6\u7f13\u5b58\u76f8\u5173<\/h3>\n<pre class=\"post-pre\"><code>open_file_cache max=100 inactive=10s;\r\nopen_file_cache_valid 30s;\r\nopen_file_cache_min_uses 2;\r\nopen_file_cache_errors on;\r\n<\/code><\/pre>\n<p>\u53c2\u8003\u9605\u8bfbnginx\u6027\u80fd\u8c03\u6574-\u9759\u6001\u5185\u5bb9\u5206\u53d1\u90e8\u5206\u3002<\/p>\n<p>\u53ef\u4ee5\u7f13\u5b58\u6587\u4ef6\u63cf\u8ff0\u7b26\u3001\u5927\u5c0f\u548c\u66f4\u65b0\u65f6\u95f4\u7b49\u4fe1\u606f\u3002<\/p>\n<h3>\u670d\u52a1\u5668\u540d\u79f0\u54c8\u5e0c\u6876\u5927\u5c0f<\/h3>\n<pre class=\"post-pre\"><code>server_names_hash_bucket_size 64\r\n<\/code><\/pre>\n<p>\u6211\u89c9\u5f97\u6682\u65f6\u6307\u5b9a64\u5c31\u53ef\u4ee5\u4e86\u3002<br \/>\n\u89e3\u51b3nginx\u9519\u8bef\u201c\u589e\u52a0server_names_hash_bucket_size\u201d\u7684\u65b9\u6cd5\u3002<\/p>\n<h3>\u7c7b\u578b\u54c8\u5e0c\u6700\u5927\u5927\u5c0f<\/h3>\n<pre class=\"post-pre\"><code>types_hash_max_size 1024;\r\n<\/code><\/pre>\n<p>\u8bbe\u7f6e\u6563\u5217\u8868\u7c7b\u578b\u7684size\u7684\u6700\u5927\u503c\u3002<\/p>\n<h3>\u54c8\u5e0c\u6876\u7684\u5927\u5c0f<\/h3>\n<pre class=\"post-pre\"><code>types_hash_bucket_size 64;\r\n<\/code><\/pre>\n<p>\u4e3a\u54c8\u5e0c\u8868\u7c7b\u578b\u8bbe\u7f6e\u6876\u5927\u5c0f\u3002<br \/>\n\u5728\u8fd9\u4e2a\u65b9\u9762\uff0c\u6211\u89c9\u5f97\u9ed8\u8ba4\u503c\u5c31\u53ef\u4ee5\u3002<\/p>\n<h3>\u542c<\/h3>\n<pre class=\"post-pre\"><code>listen 80 default_server;\r\n<\/code><\/pre>\n<p>\u5982\u679c\u76f4\u63a5\u4f7f\u7528nginx\uff0c\u53ef\u4ee5\u5728http\u5757\u5185\u8fdb\u884c\u914d\u7f6e\uff0c\u4f46\u901a\u5e38\u60c5\u51b5\u4e0b\u4f1a\u5728\u865a\u62df\u4e3b\u673a\u4e2d\u4f7f\u7528\uff0c\u56e0\u6b64\u5728\u8fd9\u91cc\u8fdb\u884c\u914d\u7f6e\u7684\u60c5\u51b5\u4e0d\u592a\u5e38\u89c1\u3002<br \/>\n\u53e6\u5916\uff0c\u5982\u679c\u6dfb\u52a0default_server\u9009\u9879\uff0c\u5219\u53ef\u4ee5\u5728\u6ca1\u6709\u5339\u914d\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u8be5\u9009\u9879\u3002<\/p>\n<h3>\u91cd\u5b9a\u5411\u4e2d\u7684\u670d\u52a1\u5668\u540d\u79f0<\/h3>\n<pre class=\"post-pre\"><code>server_name_in_redirect off;\r\n<\/code><\/pre>\n<p>\u91cd\u5b9a\u5411\u65f6\u662f\u5426\u5c06\u670d\u52a1\u5668\u540d\u79f0\u5d4c\u5165\u5230\u6807\u5934\u4e2d\u662f\u4e00\u4e2a\u95ee\u9898\uff0c\u4f46\u6211\u8ba4\u4e3a\u901a\u5e38\u4e0d\u4f1a\u9009\u62e9\u6253\u5f00\u8fd9\u4e2a\u9009\u9879\u3002<br \/>\n\u5982\u679c\u9009\u62e9\u5173\u95ed\uff0c\u5ba2\u6237\u7aef\u53d1\u9001\u7684Host\u6807\u5934\u5b57\u7b26\u4e32\u5c06\u88ab\u7528\u4f5cLocation\u7684\u4e3b\u673a\u540d\u3002<\/p>\n<h3>\u91cd\u5b9a\u5411\u7aef\u53e3<\/h3>\n<pre class=\"post-pre\"><code>port_in_redirect on;\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5df2\u5f00\u542f\uff0c\u5219\u5728\u91cd\u5b9a\u5411\u65f6\u5728 URL \u672b\u5c3e\u6dfb\u52a0\u7aef\u53e3\u53f7\u3002<\/p>\n<h3>\u4e0a\u6e38<\/h3>\n<pre class=\"post-pre\"><code>upstream unicorn {\r\n  server unix:\/path\/current\/tmp\/sockets\/unicorn.sock fail_timeout=0;\r\n}\r\n\r\nupstream server_com {\r\n      server 127.0.0.3:8000 weight=5;\r\n      server 127.0.0.3:8001 weight=5;\r\n      server 192.168.0.1:8000;\r\n      server 192.168.0.1:8001;\r\n}\r\n\r\nserver {\r\n  listen 80;\r\n  server_name unicorn;\r\n\r\n  root \/path\/current\/public;\r\n\r\n  location @unicorn {\r\n\u3000\u3000\u3000proxy_set_header X-Real-IP $remote_addr;\r\n\u3000\u3000\u3000proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n\u3000\u3000\u3000proxy_set_header Host $http_host;\r\n    proxy_pass http:\/\/unicorn;\r\n  }\r\n}\r\n\r\nserver {\r\n      listen          80;\r\n      server_name     server.com;\r\n\r\n      location \/ {\r\n        proxy_pass      http:\/\/server_com;\r\n      }\r\n}\r\n<\/code><\/pre>\n<p>\u5728\u4f7f\u7528\u540e\u7aef\u670d\u52a1\u5668\uff08\u5982\u72ec\u89d2\u517d\uff09\u65f6\uff0c\u9700\u8981\u5728\u4e0a\u6e38\u6307\u5b9a\u5957\u63a5\u5b57\uff08\u6211\u66fe\u7ecf\u7531\u4e8e\u6307\u5b9a\u4e86\u9519\u8bef\u7684\u8fdb\u7a0bID\u800c\u5bfc\u81f4\u65e0\u6cd5\u5de5\u4f5c\uff0c\u975e\u5e38\u5c34\u5c2c\uff09\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a\u670d\u52a1\u5668\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n<h3>\u8bbe\u5b9a\u4ee3\u7406\u8bf7\u6c42\u5934\u7b49<\/h3>\n<pre class=\"post-pre\"><code>proxy_pass http:\/\/127.0.0.1:3000;\r\nproxy_set_header Host $host;\r\nproxy_set_header X-Real-IP $remote_addr;\r\nproxy_set_header X-Forwarded-Server $host;\r\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\nproxy_hide_header X-Powered-By;\r\nproxy_ignore_headers Expires;\r\n<\/code><\/pre>\n<p>\u91cd\u65b0\u5b9a\u4e49\u8981\u53d1\u9001\u5230\u540e\u7aef\u670d\u52a1\u5668\u7684\u6807\u5934\u3002<br \/>\n\u6211\u8ba4\u4e3a\u4f7f\u7528\u4ee5\u4e0a\u8bbe\u7f6e\u57fa\u672c\u4e0a\u6ca1\u6709\u95ee\u9898\u3002<\/p>\n<p>\u5f53\u4f7f\u7528\u53cd\u5411\u4ee3\u7406\u65f6\uff0c\u9700\u8981\u5148\u5b9a\u4e49proxy_pass\u3002<br \/>\nnginx\u4e2d\u7684proxy_set_header\u8bbe\u7f6e\u4f4d\u7f6e\u3002<\/p>\n<p>\u5bf9\u4e8e\u50cfUnicorn\u7684Socket\u901a\u4fe1\u8fd9\u6837\u7684\u60c5\u51b5\uff0c\u5728\u540e\u9762\u5199\u4e0aproxy_pass\u4f3c\u4e4e\u6ca1\u6709\u95ee\u9898\u3002<\/p>\n<p>proxy_hide_header\u6307\u4ee4\u7528\u4e8e\u9690\u85cf\u5934\u6587\u4ef6\u4fe1\u606f\uff0c\u4ee5\u4fdd\u969c\u5b89\u5168\u6027\u5e76\u9632\u6b62\u5411\u5ba2\u6237\u7aef\u6cc4\u6f0f\u4e0d\u5e0c\u671b\u516c\u5f00\u7684\u4fe1\u606f\u3002<\/p>\n<p>\u5ffd\u7565proxy_ignore_headers\u4e2d\u6307\u5b9a\u7684\u503c\u3002\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u5c06\u5ffd\u7565Expires\uff0c\u56e0\u6b64\u4e0d\u4f1a\u88ab\u7f13\u5b58\u2026\uff08\u5e76\u4e0d\u662f\u5f88\u7406\u89e3\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>proxy_connect_timeout\r\nproxy_send_timeout\r\nproxy_read_timeout\r\n<\/code><\/pre>\n<p>\u8fd8\u6709\u5176\u4ed6\u4e00\u4e9b\u8bbe\u7f6e\u53ef\u4f9b\u9009\u62e9\u3002<br \/>\n\u8be6\u7ec6\u60c5\u51b5\u8bf7\u53c2\u8003\u304a\u540d\u524d.com VPS\u4e0a\u901a\u8fc7Nginx\u642d\u5efaWordPress\u3002\u603b\u7ed3\u7684\u8bbe\u7f6e\u542b\u4e49\u4e5f\u5f88\u6e05\u695a\u6613\u61c2\u3002<\/p>\n<p>\u6211\u8ba4\u4e3a\u8fd9\u662f\u76f8\u5f53\u91cd\u8981\u7684\u8bbe\u7f6e\uff0c\u6240\u4ee5\u6211\u6765\u7b80\u5355\u89e3\u91ca\u4e00\u4e0b\u3002\u4ee5\u5c06upstream server\u8bbe\u7f6e\u4e3aunicorn\uff08Rails\uff09\u7684nginx\u4e3a\u4f8b\u8fdb\u884c\u89e3\u91ca\u3002<\/p>\n<h4>\u8fde\u63a5\u4ee3\u7406\u8d85\u65f6<\/h4>\n<p>\u5c06\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4\u4ecenginx\u5207\u6362\u5230unicorn\u3002<br \/>\n\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u8fde\u63a5\u5e94\u8be5\u57281\u79d2\u5de6\u53f3\u5efa\u7acb\u3002<br \/>\n\u6700\u957f\u4e3a75\u79d2\uff0c\u4f46\u662f\u6211\u8ba4\u4e3a\u8bbe\u7f6e\u4e3a10\u79d2\u5de6\u53f3\u5c31\u8db3\u591f\u4e86\u3002<\/p>\n<h4>\u4ee3\u7406\u53d1\u9001\u8d85\u65f6<\/h4>\n<p>\u8fd9\u662f\u5728\u5c06\u6570\u636e\u4ecenginx\u53d1\u9001\u5230unicorn\u65f6\u7684\u8d85\u65f6\u503c\u3002<br \/>\n\u7531\u4e8e\u53d1\u9001\u6240\u9700\u7684\u65f6\u95f4\u5f88\u77ed\uff0c\u6211\u8ba4\u4e3a\u8bbe\u7f6e\u4e3a10\u79d2\u5e94\u8be5\u8db3\u591f\u3002<br \/>\n\uff08\u65e0\u8bba\u53d1\u9001\u591a\u5927\u7684\u6587\u4ef6\uff0c\u5728HTTP\u8bf7\u6c42\u4e2d\u8003\u8651\uff0c\u6211\u8ba4\u4e3a\u51e0\u79d2\u949f\u5c31\u80fd\u5b8c\u6210\u3002\uff09<\/p>\n<h4>\u4ee3\u7406\u670d\u52a1\u8bfb\u53d6\u8d85\u65f6<\/h4>\n<p>\u8fd9\u4e2a\u503c\u662f\u6700\u91cd\u8981\u7684\u3002<br \/>\n\u6839\u636e\u4f20\u9012\u7684\u6587\u4ef6\uff08\u6570\u636e\uff09\u8fdb\u884c\u5904\u7406\uff0c\u6211\u8ba4\u4e3a\u72ec\u89d2\u517d\u4f1a\u5904\u7406\u5b83\uff0c\u4f46\u4e00\u65e6\u8d85\u8fc7\u8fd9\u4e2a\u503c\uff0c\u8fde\u63a5\u5c31\u4f1a\u65ad\u5f00\u3002<br \/>\n\u6240\u4ee5\uff0c\u5728\u8ba9\u72ec\u89d2\u517d\u5904\u7406\u7684\u60c5\u51b5\u4e0b\uff0c\u9700\u8981\u8bbe\u7f6e\u9884\u60f3\u7684\u6700\u5927\u65f6\u95f4\u3002<br \/>\n\uff08\u6bd4\u5982\u5904\u7406\u5927\u578bCSV\u6587\u4ef6\u65f6\uff0c\u5efa\u8bae\u5c06\u8fd9\u4e2a\u503c\u8bbe\u7f6e\u5f97\u66f4\u957f\uff01\uff09<\/p>\n<p>\u6b64\u5916\uff0c\u7368\u89d2\u7378\uff08unicorn\uff09\u4e5f\u6709\u8d85\u6642\u8a2d\u5b9a\uff0c\u56e0\u6b64\u9700\u8981\u5c07\u8d85\u6642\u6642\u9593\u8a2d\u5b9a\u5f97\u6bd4\u7368\u89d2\u7378\u7684\u8d85\u6642\u6642\u9593\u66f4\u9577\u3002<\/p>\n<h3>\u4ee3\u7406\u91cd\u5b9a\u5411<\/h3>\n<pre class=\"post-pre\"><code>proxy_redirect off;\r\n<\/code><\/pre>\n<p>\u5f53\u540e\u7aef\u670d\u52a1\u5668\u91cd\u5b9a\u5411\u65f6\u7684Location\u5934\u90e8\u3002\u5f53\u4e3a&#8221;on&#8221;\u65f6\uff0c\u4ee5\u4ee3\u7406\u7684\u65b9\u5f0f\u5c06\u5176\u91cd\u5b9a\u5411\u5230\u4e3b\u673a\u540d\u3002\u5f53\u4e3a&#8221;off&#8221;\u65f6\uff0c\u6309\u7167\u670d\u52a1\u5668\u7684\u6307\u793a\u8fdb\u884c\u91cd\u5b9a\u5411\u3002<\/p>\n<h3>\u9519\u8bef\u9875\u9762\u3001\u4ee3\u7406\u62e6\u622a\u9519\u8bef<\/h3>\n<pre class=\"post-pre\"><code>proxy_intercept_errors on;\r\nerror_page 404             \/404.html;\r\nerror_page 403 =404 \/notfound.html; # 403\u306e\u5834\u5408404\u306b\u5909\u63db\u3055\u308c\u308b\u3002\r\nerror_page 500 502 503 504 \/50x.html;\r\n<\/code><\/pre>\n<p>\u6839\u636e\u9519\u8bef\u72b6\u6001\u663e\u793a\u76f8\u5e94\u7684\u9875\u9762\u3002<\/p>\n<p>\u5728\u670d\u52a1\u5668\u6216\u4f4d\u7f6e\u5757\u4e2d\u5747\u53ef\u4f7f\u7528\u3002<\/p>\n<p>\u9700\u8981\u5c06proxy_intercept_errors\u8bbe\u7f6e\u4e3aon\u3002<\/p>\n<h3>\u5305\u62ec\/etc\/nginx\/vhost.d\/\u4e0b\u7684\u6240\u6709.conf\u6587\u4ef6\u3002<\/h3>\n<pre class=\"post-pre\"><code>include \/etc\/nginx\/vhost.d\/*.conf;\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8981\u5c06\u670d\u52a1\u5668\u7b49\u5b9a\u4e49\u5728\u53e6\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u5219\u6267\u884c\u4e0a\u8ff0\u914d\u7f6e\u3002\u8fd9\u5c06\u4f7f\u6307\u5b9a\u6587\u4ef6\u5939\u4e2d\u7684\u6587\u4ef6\u88ab\u52a0\u8f7d\u3002\uff08\u5982\u679c\u5728http\u5757\u4e2d\u8fdb\u884c\u63cf\u8ff0\uff0c\u5219\u4f1a\u5c55\u5f00\u5230http\u5757\u4e2d\uff0c\u56e0\u6b64\u5728\u5355\u72ec\u7684\u6587\u4ef6\u4e2d\u4e0d\u9700\u8981\u7f16\u5199http{}\u3002\uff09<\/p>\n<h2>\u670d\u52a1\u5668\u5757<\/h2>\n<pre class=\"post-pre\"><code>http {\r\n    server {\r\n        ...\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u4f7f\u7528nginx\u6765\u64cd\u4f5c\u865a\u62df\u4e3b\u673a\u65f6\u4f7f\u7528\u3002<br \/>\n\u865a\u62df\u4e3b\u673a\u662f\u5728\u4ee5server\u4e3a\u5355\u4f4d\u5212\u5206\u7684\u3002<\/p>\n<p>\u8bf7\u5728http\u5757\u5185\u4f5c\u4ee5\u4e0b\u8bb0\u8ff0\u3002<\/p>\n<p>\u670d\u52a1\u5668\u5757\u5185\u7684\u63cf\u8ff0\u57fa\u672c\u4e0a\u4e5f\u53ef\u4ee5\u5728location\u4e2d\u4f7f\u7528\u3002(\u65e0\u6cd5\u4f7f\u7528listen\u3001server_name\u3001root\u3002)<\/p>\n<h3>\u542c\u548c\u670d\u52a1\u5668\u540d\u79f0<\/h3>\n<pre class=\"post-pre\"><code>listen 80 default_server;\r\nserver_name localhost;\r\n<\/code><\/pre>\n<p>\u8fd9\u662f\u8bbf\u95ee\u8be5\u865a\u62df\u4e3b\u673a\u7684\u4fe1\u606f\u3002<br \/>\n\u867d\u7136\u201clisten\u201d\u4e5f\u53ef\u4ee5\u6307\u5b9aIP\u5730\u5740\u7b49\uff0c\u4f46\u6211\u53ea\u6307\u5b9a\u4e86\u7aef\u53e3\u53f7\u3002<br \/>\n\u5982\u679c\u6307\u5b9a\u201cdefault_server\u201d\uff0c\u5b83\u5c06\u6210\u4e3a\u7528\u4e8e\u4e0d\u5339\u914d\u5176\u4ed6\u6240\u6709\u60c5\u51b5\u7684\u670d\u52a1\u5668\u3002<br \/>\n\u6b64\u5916\uff0c\u201clisten\u201d\u4f3c\u4e4e\u6709\u5404\u79cd\u9009\u9879\u3002\u8bf7\u53c2\u8003\u8fd9\u91cc\u3002<\/p>\n<p>\u5982\u679cserver_name\u4e0e\u6307\u5b9a\u7684\u57df\u540d\u5339\u914d\uff0c\u5c06\u9002\u7528\u4e8e\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7684http:\/\/localhost:80\u3002<\/p>\n<h3>\u6839\u6e90<\/h3>\n<pre class=\"post-pre\"><code>root \/path\/public\r\n<\/code><\/pre>\n<p>\u5728\u6b64\u670d\u52a1\u5668\u5757\u5185\u6307\u5b9a\u8981\u4f7f\u7528\u7684\u6839\u76ee\u5f55\u3002<\/p>\n<h3>\u8bf7\u5c06\u4ee5\u4e0b\u5185\u5bb9\u7528\u4e2d\u6587\u8fdb\u884c\u672c\u5730\u5316\u6539\u5199\uff1a<\/h3>\n<p>\u6539\u5199<\/p>\n<pre class=\"post-pre\"><code>rewrite \/(.*)\/index.html $1.html permanent;\r\n<\/code><\/pre>\n<p>\u5982\u679c\u60a8\u60f3\u8981\u91cd\u5b9a\u5411\uff0c\u8bf7\u4f7f\u7528\u6b64\u9009\u9879\u3002<\/p>\n<h3>\u6ee1\u8db3\uff0c\u57fa\u672c\u8ba4\u8bc1<\/h3>\n<pre class=\"post-pre\"><code>satisfy any;\r\nauth_basic \"basic authentication\";\r\nauth_basic_user_file \/etc\/nginx\/.htpasswd;\r\n<\/code><\/pre>\n<p>\u5982\u679c\u67d0\u4e9b\u5730\u5740\u4e0d\u9700\u8981\u8fdb\u884c\u57fa\u672c\u8ba4\u8bc1\uff0c\u53ef\u4ee5\u4f7f\u7528satisfy\u3002\u8fd9\u4e2a\u7f51\u7ad9\u5f88\u5bb9\u6613\u7406\u89e3\u3002<br \/>\nauth_basic\u7528\u4e8e\u663e\u793a\u8ba4\u8bc1\u540d\u79f0\u3002<br \/>\nauth_basic_user_file\u7528\u4e8e\u6307\u5b9a\u5bc6\u7801\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/p>\n<h3>\u8bd5\u56fe\u627e\u5230\u6587\u4ef6<\/h3>\n<pre class=\"post-pre\"><code>try_files $uri $uri.html $uri\/index.html @unicorn;\r\n<\/code><\/pre>\n<p>\u5c06\u6839\u636e\u5de6\u4fa7\u7684\u987a\u5e8f\u53bb\u67e5\u627e\u6307\u5b9a\u6587\u4ef6\u7684\u5b58\u5728\u3002\u4f8b\u5982\u8bbf\u95eehttp:\/\/***\/hoge\u65f6\uff0c\u9996\u5148\u4f1a\u67e5\u627ehoge.html\uff0c\u7136\u540e\u662fhoge\/index.html\uff0c\u6700\u540e\u662flocation @unicorn {}\u3002<\/p>\n<h2>\u5730\u70b9\u533a\u5757<\/h2>\n<pre class=\"post-pre\"><code>http {\r\n    server {\r\n        location \/ {\r\n            ...\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u53ea\u9002\u7528\u4e8e\u6307\u5b9a\u7684\u4f4d\u7f6e\uff08\u8def\u5f84\u6216\u6587\u4ef6\uff09\u3002<\/p>\n<p>\u4ee5\u4e0b\u7684\u5185\u5bb9\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u6307\u5b9a\u3002<\/p>\n<pre class=\"post-pre\"><code>location ~ \/\\.(ht|svn|git) {\r\n    deny all;\r\n}\r\n<\/code><\/pre>\n<p>\u5f53\u60a8\u4e0d\u5e0c\u671b\u8bbf\u95ee.htaccess\u3001.svn\u3001.git\u7b49\u6587\u4ef6\u65f6\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0a\u8bbe\u7f6e\u3002<\/p>\n<h3>stub_status\u3001\u5141\u8bb8\u3001\u62d2\u7edd<\/h3>\n<pre class=\"post-pre\"><code>stub_status on;\r\naccess_log off;\r\nallow 127.0.0.1;\r\ndeny all;\r\n<\/code><\/pre>\n<p>\u5f53\u8bbf\u95ee\u5e26\u6709\u201cstub_status\u201d\u7684\u4f4d\u7f6e\u65f6\uff0c\u60a8\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u8fde\u63a5\u6570\u7b49\u4fe1\u606f\u3002<br \/>\n\u901a\u5e38\u4e0d\u4f1a\u5411\u5916\u754c\u516c\u5f00\u8be5\u4fe1\u606f\u3002<\/p>\n<p>\u5982\u679c\u6307\u5b9a\u5141\u8bb8 (allow) \uff0c\u5219\u5141\u8bb8\u6765\u81ea\u76ee\u6807IP\u7684\u8bbf\u95ee\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5141\u8bb8127.0.0.1\u3002<\/p>\n<p>\u5982\u679c\u6307\u5b9a\u4e86\u62d2\u7edd\uff08deny\uff09\u9009\u9879\uff0c\u5219\u7981\u6b62\u6765\u81ea\u76ee\u6807IP\u7684\u8bbf\u95ee\u3002\u8fd9\u91cc\u7981\u6b62\u4e86\u6240\u6709\u7684\u8bbf\u95ee\u3002<\/p>\n<p>\u7531\u4e8eNginx\u4ece\u4e0a\u5230\u4e0b\u8fdb\u884c\u8bc4\u4f30\uff0c\u5728\u4e0a\u8ff0\u60c5\u51b5\u4e0b\uff0callow 127.0.0.1\u4f1a\u88ab\u4f18\u5148\u8bc4\u4f30\uff0c\u56e0\u6b64\u4ec5\u5141\u8bb8127.0.0.1\u7684\u8bbf\u95ee\u88ab\u5e94\u7528\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u5982\u679c\u4ee5\u76f8\u53cd\u7684\u65b9\u5f0f\u63cf\u8ff0\u5982\u4e0b\uff0c\u5c06\u62d2\u7edd\u6765\u81ea\u6240\u6709IP\u5730\u5740\u7684\u8bbf\u95ee\u3002\uff08\u8bf7\u6ce8\u610f\uff0c\u8fd9\u4e0eApache\u4e0d\u540c\u3002\uff09<\/p>\n<pre class=\"post-pre\"><code>deny all;\r\nallow 127.0.0.1;\r\n<\/code><\/pre>\n<p>\u56e0\u4e3a\u6211\u6ca1\u6709\u627e\u5230\u6709\u5173 allow \u548c deny \u662f\u5426\u53ef\u4ee5\u4f7f\u7528\u57df\u540d\u7684\u6587\u7ae0\uff0c\u6240\u4ee5\u65e0\u6cd5\u786e\u5b9a\u3002\u7136\u800c\uff0c\u5982\u679c\u6307\u5b9a\u4e86\u57df\u540d\uff0c\u5219\u4f1a\u9700\u8981\u8bbf\u95ee DNS \u670d\u52a1\u5668\u8fdb\u884c\u5224\u65ad\uff0c\u6240\u4ee5\u57fa\u672c\u4e0a\u4e0d\u4f1a\u8fd9\u6837\u505a\u3002<\/p>\n<h3>\u8fc7\u671f<\/h3>\n<pre class=\"post-pre\"><code>expires 10d;\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528\u6d4f\u89c8\u5668\u7f13\u5b58\u7684\u8bdd\uff0c\u5c31\u4f7f\u7528\u5b83\u3002\u5728\u4e0a\u8ff0\u7684\u4f8b\u5b50\u4e2d\uff0c\u5c06\u4f7f\u7528\u6d4f\u89c8\u5668\u7f13\u5b5810\u5929\u3002<\/p>\n<h3>\u6dfb\u52a0\u5934\u90e8<\/h3>\n<pre class=\"post-pre\"><code>add_header Cache-Control public;\r\n<\/code><\/pre>\n<p>\u8bbe\u5b9a\u8981\u9644\u52a0\u5728\u54cd\u5e94\u5934\u7684\u503c\u3002<br \/>\n\u53ef\u53c2\u8003\u4ee5\u4e0bURL\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx \u3092\u77e5\u308b:: \u5f8c\u7de8<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">HTTP \u30ad\u30e3\u30c3\u30b7\u30e5 \u30d8\u30c3\u30c0\u306e\u8a2d\u5b9a &#8211; Cache-Control<\/ul>\n<h3>\u6253\u7834<\/h3>\n<pre class=\"post-pre\"><code>break;\r\n<\/code><\/pre>\n<p>\u6211\u5011\u4e4b\u5f8c\u5c07\u4e0d\u518d\u9032\u884c\u91cd\u5beb\u7684\u8655\u7406\u3002<\/p>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0b\u94fe\u63a5\uff1anginx rewrite\u4e2dlast\u548cbreak\u7684\u533a\u522b<\/p>\n<h3>\u5185\u90e8 b\u00f9)<\/h3>\n<pre class=\"post-pre\"><code>error_page 404 \/404.html;\r\n\r\nlocation \/404.html {\r\n    internal;\r\n}\r\n<\/code><\/pre>\n<p>\u5982\u679c\u53ea\u60f3\u5728\u5185\u90e8\u91cd\u5b9a\u5411\u4e2d\u4f7f\u7528\uff0c\u8bf7\u4f7f\u7528\u6b64\u9009\u9879\u3002<br \/>\n\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u60a8\u65e0\u6cd5\u76f4\u63a5\u67e5\u770b\/404.html\u9875\u9762\u3002<\/p>\n<h2>\u53c2\u8003\u94fe\u63a5:<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx\u6700\u5927\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u51fa\u3059\u305f\u3081\u306e\u57fa\u672c\u8a2d\u5b9a<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u304a\u540d\u524d.com VPS \u306bNginx\u3067WordPress\u3092\u69cb\u7bc9\u3002\u8a2d\u5b9a\u306e\u610f\u5473\u3082\u307e\u3068\u3081\u305f<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx\u9023\u8f093\u56de\u76ee: nginx\u306e\u8a2d\u5b9a\u3001\u305d\u306e1<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u3068h2o<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Laravel\u3068Nginx\u306e\u5feb\u901f\u4ed5\u7acb\u3066\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u6dfb\u3048\u306a\u3044\u3067\u2026<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx \u3067KeepAlive\u3092\u8a2d\u5b9a\u3057\u3066\u307f\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Nginx \u3067 Elastic Load Balancing \u306a\u3069\u306e Proxy \u306e\u5185\u5074\u3067\u6b63\u3057\u3044 IP \u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u30dc\u30c7\u30a3\u306e\u30d0\u30c3\u30d5\u30a1\u30ea\u30f3\u30b0\u306b\u95a2\u3059\u308b\u554f\u984c\u3068\u305d\u306e\u6539\u5584\u7b56<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u301c\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u914d\u4fe1\u7de8\u301c<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">ngx_http_core_module \u30e2\u30b8\u30e5\u30fc\u30eb<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">ngx_http_proxy_module \u30e2\u30b8\u30e5\u30fc\u30eb<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">ngx_http_gzip_module \u30e2\u30b8\u30e5\u30fc\u30eb<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148 \u6211\u53ea\u662f\u76f2\u76ee\u5730\u4f7f\u7528nginx\u6765\u542f\u52a8unicorn\uff0c\u51e0\u4e4e\u4e0d\u4e86\u89e3\u914d\u7f6e\u6587\u4ef6\u7684\u5185\u5bb9\u3002 \u6240\u4ee5\u6211\u60f3\u5728\u8fd9\u91cc\u603b\u7ed3nginx [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-32950","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nginx\u914d\u7f6e\u6458\u8981 - Blog - Silicon Cloud<\/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.silicloud.com\/zh\/blog\/nginx\u914d\u7f6e\u6458\u8981\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nginx\u914d\u7f6e\u6458\u8981\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148 \u6211\u53ea\u662f\u76f2\u76ee\u5730\u4f7f\u7528nginx\u6765\u542f\u52a8unicorn\uff0c\u51e0\u4e4e\u4e0d\u4e86\u89e3\u914d\u7f6e\u6587\u4ef6\u7684\u5185\u5bb9\u3002 \u6240\u4ee5\u6211\u60f3\u5728\u8fd9\u91cc\u603b\u7ed3nginx [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/nginx\u914d\u7f6e\u6458\u8981\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-20T22:15:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-03T22:24:21+00:00\" \/>\n<meta name=\"author\" content=\"\u6e05, \u5b87\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u5b87\" \/>\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.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/\",\"name\":\"Nginx\u914d\u7f6e\u6458\u8981 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-10-20T22:15:48+00:00\",\"dateModified\":\"2024-05-03T22:24:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nginx\u914d\u7f6e\u6458\u8981\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\",\"name\":\"\u6e05, \u5b87\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u5b87\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Nginx\u914d\u7f6e\u6458\u8981 - Blog - Silicon Cloud","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.silicloud.com\/zh\/blog\/nginx\u914d\u7f6e\u6458\u8981\/","og_locale":"zh_CN","og_type":"article","og_title":"Nginx\u914d\u7f6e\u6458\u8981","og_description":"\u9996\u5148 \u6211\u53ea\u662f\u76f2\u76ee\u5730\u4f7f\u7528nginx\u6765\u542f\u52a8unicorn\uff0c\u51e0\u4e4e\u4e0d\u4e86\u89e3\u914d\u7f6e\u6587\u4ef6\u7684\u5185\u5bb9\u3002 \u6240\u4ee5\u6211\u60f3\u5728\u8fd9\u91cc\u603b\u7ed3nginx [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/nginx\u914d\u7f6e\u6458\u8981\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-10-20T22:15:48+00:00","article_modified_time":"2024-05-03T22:24:21+00:00","author":"\u6e05, \u5b87","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u5b87","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/","name":"Nginx\u914d\u7f6e\u6458\u8981 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-10-20T22:15:48+00:00","dateModified":"2024-05-03T22:24:21+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Nginx\u914d\u7f6e\u6458\u8981"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e","name":"\u6e05, \u5b87","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","caption":"\u6e05, \u5b87"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/nginx%e9%85%8d%e7%bd%ae%e6%91%98%e8%a6%81\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=32950"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32950\/revisions"}],"predecessor-version":[{"id":96651,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32950\/revisions\/96651"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=32950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=32950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=32950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}