1,nginx后台error日志报错
<code class="hljs vbscript has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2016</span>/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">02</span>/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">05</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">23</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">56</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">error</span>] <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12024</span>#<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>: *<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">441106971</span> connect() failed (<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">111</span>: Connection refused) <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">while</span> connecting <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> upstream, client: <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">113.214</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.10</span>, <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">server</span>: localhost, <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">request</span>: <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"GET /h5teb/ugcH5/index.htm?source=android&mall=8&TGC=911FDD2F99B84D528F0A7EE71780A943 HTTP/1.1"</span>, upstream: <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"http://113.214.1.23:8000/h5teb/ugcH5/index.htm?source=android&mall=8&TGC=911FDD2F99B84D528F0A7EE71780A943"</span>, host: <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"www.testcrm.com"</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2016</span>/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">02</span>/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">05</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">48</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">error</span>] <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12013</span>#<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>: *<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">441119082</span> client intended <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">to</span> send too large body: <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1331696</span> bytes, client: <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">113.214</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.10</span>, <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">server</span>: localhost, <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">request</span>: <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"POST /h5teb/complaints/save.htm HTTP/1.1"</span>, host: <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"www.testcrm.com"</span>, referrer: <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"http://www.testcrm.com/h5teb/complaints/index.htm"</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right; opacity: 0.0385924;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
2,web工程中添加对文件上传的限制
web工程部署了一个单独的nginx,在http{后面添加限制100m的上限
<code class="hljs applescript has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">client_max_body_size <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">100</span>m; [nginx@wgq_idc_web_1_21 logs]$ vim /usr/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">local</span>/nginx/conf/nginx.conf http { include mime.types; server_tokens off; sendfile <span class="hljs-function_start" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">on</span></span>; tcp_nopush <span class="hljs-function_start" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">on</span></span>; tcp_nodelay <span class="hljs-function_start" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">on</span></span>; keepalive_timeout <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">65</span>; log_format main '$proxy_add_x_forwarded_for $remote_user [$time_local] <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"$request"</span> ' '$status $body_bytes_sent <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"$http_referer"</span> ' '<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"$http_user_agent"</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"$http_x_forwarded_for"</span> ' 'upstream: $upstream_addr'; access_log off; client_max_body_size <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">100</span>m;</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right; opacity: 0.0385924;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li></ul>
3,静态资源中添加对文件上传的限制
静态资源部署了一个单独的nginx,在转发location中进行配置100m的上限,client_max_body_size 100m;:
<code class="hljs haskell has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">[fastdfs@wgq_test_crm~]$ vim /usr/local/nginx/conf/nginx.conf location /group1/<span class="hljs-type" style="box-sizing: border-box; color: rgb(102, 0, 102);">M00</span> { root /<span class="hljs-typedef" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">data</span>/fastdfs/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">data</span>;</span> include gzip.conf; ngx_fastdfs_module; client_max_body_size <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">100</span>m; expires <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>h; } location /group2/<span class="hljs-type" style="box-sizing: border-box; color: rgb(102, 0, 102);">M00</span> { root /<span class="hljs-typedef" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">data</span>/fastdfs_group2/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">data</span>;</span> ngx_fastdfs_module; client_max_body_size <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">100</span>m; #access_log /usr/local/nginx/logs/group2_pic.log main; expires <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>h; include gzip.conf; }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right; opacity: 0.0385924;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li></ul>