{"id":3969,"date":"2019-03-08T16:08:31","date_gmt":"2019-03-08T08:08:31","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3969"},"modified":"2019-03-08T16:08:31","modified_gmt":"2019-03-08T08:08:31","slug":"goaccess-%e5%ae%9e%e7%8e%b0-nginx-access-%e6%97%a5%e5%bf%97%e5%8f%af%e8%a7%86%e5%8c%96%e6%98%be%e7%a4%ba%e5%92%8c%e5%ae%9e%e6%97%b6%e7%9b%91%e6%8e%a7","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3969","title":{"rendered":"GoAccess \u5b9e\u73b0 Nginx access \u65e5\u5fd7\u53ef\u89c6\u5316\u663e\u793a\u548c\u5b9e\u65f6\u76d1\u63a7"},"content":{"rendered":"<p>\n\t\u5f00\u53d1\u4e00\u4e2a\u7cfb\u7edf\uff0c\u5927\u5bb6\u7b2c\u4e00\u65f6\u95f4\u5e94\u8be5\u60f3\u5230\u7684\u5c31\u662f\u65e5\u5fd7\u3002\u8fd9\u4e5f\u662f\u5f88\u591a\u67b6\u6784\u5e08\u8981\u8003\u8651\u7684\u4e8b\u60c5\u3002\n<\/p>\n<p>\n\t\u6bd4\u5982\uff0c\u6211\u6709\u4e0a\u4e07\u53f0\u673a\u5668\u7684\u8bdd\uff0c\u6bcf\u53f0\u673a\u5668\u90fd\u4f1a\u4ea7\u751f\u65e5\u5fd7\u3002\u5982\u679c\u5176\u4e2d\u6709 10 \u53f0\u673a\u5668\u4e2d\u7684\u7a0b\u5e8f\u62a5\u4e86\u4e00\u4e2a error\uff0c\u4f60\u4e0d\u53ef\u80fd\u5728\u767b\u5f55\u4e0a\u53bb\u770b\u5427\u3002\u800c\u4e14\uff0c\u767b\u5f55\u7cfb\u7edf\u90fd\u662f\u9700\u8981\u4e34\u65f6\u5ba1\u6279\u6743\u9650\u7684\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u8981\u6709\u66f4\u9ad8\u6548\u7684\u65e5\u5fd7\u7ba1\u7406\u529e\u6cd5\u3002\n<\/p>\n<p>\n\t\u6709\u4eba\u53ef\u80fd\u4f1a\u60f3\u5230 ELK\uff0c\u662f\u7684\uff0cELK \u786e\u5b9e\u725b\u3002\u4f46\u662f\u5bf9\u4e8e\u4e00\u4e9b\u5c0f\u516c\u53f8\u6765\u8bf4 ELK \u5c31\u592a\u7b28\u91cd\u4e86\u3002\u800c\u4e14\u9488\u5bf9 Nginx \u6216\u8005 Apache\uff0c\u6211\u4eec\u9700\u8981\u5176\u4ed6\u7684\u65e5\u5fd7\u53ef\u89c6\u5316\u663e\u793a\u548c\u76d1\u63a7\u7cfb\u7edf\uff0c\u90a3\u4e48 GoAccess \u5c31\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\uff01\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"GoAccess \u5b9e\u73b0 Nginx access \u65e5\u5fd7\u53ef\u89c6\u5316\u663e\u793a\u548c\u5b9e\u65f6\u76d1\u63a7\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g0vg9figj8j20ys0d40wb.jpg\" style=\"width: 1252px;height: 472px\" \/>\n<\/p>\n<h2>\n\tGoAccess \u662f\u4ec0\u4e48\uff1f<br \/>\n<\/h2>\n<p>\n\tGoAccess \u662f\u4e00\u4e2a\u91c7\u7528c\u8bed\u8a00\u5f00\u53d1\u7684\u6765\u5206\u6790\u7edf\u8ba1Web\u670d\u52a1\u5668\u7684\u8bbf\u95ee\u65e5\u5fd7\u7684\u5de5\u5177\uff0c\u901f\u5ea6\u975e\u5e38\u5feb\uff0c\u53ef\u5373\u65f6\u751f\u6210\u81ea\u5b9a\u4e49\u7684\u7edf\u8ba1\u62a5\u8868\uff0c\u57fa\u4e8e\u547d\u4ee4\u884c\u64cd\u4f5c\u3002\n<\/p>\n<h2>\n\tGoAccess \u7684\u5b89\u88c5<br \/>\n<\/h2>\n<p>\n\t\u5b98\u65b9\u7ed9\u7684 GoAccess \u5b89\u88c5\u6559\u7a0b\u975e\u5e38\u7684\u7b80\u5355\uff0c\u53ea\u9700\u4e0b\u8f7d\u3001\u63d0\u53d6\u548c\u7f16\u8bd1\u5373\u53ef\u3002\n<\/p>\n<pre class=\"brush:java;\">\r\nwget https:\/\/tar.goaccess.io\/goaccess-1.3.tar.gz\r\ntar -xzvf goaccess-1.3.tar.gz\r\ncd goaccess-1.3\/\r\n.\/configure --enable-utf8 --enable-geoip=legacy\r\nmake\r\nmake install<\/pre>\n<h2>\n\tGoAccess \u7684\u914d\u7f6e<br \/>\n<\/h2>\n<p>\n\tGoAccess \u62e5\u6709\u591a\u4e2a\u914d\u7f6e\u9009\u9879\u3002\u83b7\u53d6\u5b8c\u6574\u7684\u6700\u65b0\u914d\u7f6e\u9009\u9879\u5217\u8868\uff0c\u8bf7\u8fd0\u884c\uff1a.\/configure &mdash;help\u3002\n<\/p>\n<ul>\n<li>\n\t\t&#8211;enable-debug\uff1a\u4f7f\u7528\u8c03\u8bd5\u6807\u5fd7\u7f16\u8bd1\u4e14\u5173\u95ed\u7f16\u8bd1\u5668\u4f18\u5316\u3002\n\t<\/li>\n<li>\n\t\t&#8211;enable-utf8\uff1a\u5bbd\u5b57\u7b26\u652f\u6301\u3002\u4f9d\u8d56 Ncursesw \u6a21\u5757\u3002\n\t<\/li>\n<li>\n\t\t&#8211;enable-geoip=&lt;legacy|mmdb&gt;\uff1a\u5730\u7406\u4f4d\u7f6e\u652f\u6301\u3002\u4f9d\u8d56 MaxMind GeoIP \u6a21\u5757\u3002 legacy \u5c06\u4f7f\u7528\u539f\u59cb GeoIP \u6570\u636e\u5e93\u3002 mmdb \u5c06\u4f7f\u7528\u589e\u5f3a\u7248 GeoIP2 \u6570\u636e\u5e93\u3002\n\t<\/li>\n<li>\n\t\t&#8211;enable-tcb=&lt;memhash|btree&gt;\uff1aTokyo Cabinet \u5b58\u50a8\u652f\u6301\u3002 memhash \u5c06\u4f7f\u7528 Tokyo Cabinet \u7684\u5185\u5b58\u54c8\u5e0c\u6570\u636e\u5e93\u3002btree \u5c06\u4f7f\u7528 Tokyo Cabinet \u7684\u78c1\u76d8 B+Tree \u6570\u636e\u5e93\u3002\n\t<\/li>\n<li>\n\t\t&#8211;disable-zlib\uff1a\u7981\u6b62\u5728 B+Tree \u6570\u636e\u5e93\u4e0a\u4f7f\u7528 zlib \u538b\u7f29\u3002\n\t<\/li>\n<li>\n\t\t&#8211;disable-bzip\uff1a\u7981\u6b62\u5728 B+Tree \u6570\u636e\u5e93\u4e0a\u4f7f\u7528 bzip2 \u538b\u7f29\u3002\n\t<\/li>\n<li>\n\t\t&#8211;with-getline\uff1a\u4f7f\u7528\u52a8\u6001\u6269\u5c55\u884c\u7f13\u51b2\u533a\u7528\u6765\u89e3\u6790\u5b8c\u6574\u7684\u884c\u8bf7\u6c42\uff0c\u5426\u5219\u5c06\u4f7f\u7528\u56fa\u5b9a\u5927\u5c0f(4096)\u7684\u7f13\u51b2\u533a\u3002\n\t<\/li>\n<li>\n\t\t&#8211;with-openssl\uff1a\u4f7f GoAccess \u4e0e\u5176 WebSocket \u670d\u52a1\u5668\u4e4b\u95f4\u7684\u901a\u4fe1\u80fd\u591f\u652f\u6301 OpenSSL\u3002\n\t<\/li>\n<\/ul>\n<h2>\n\tGoAccess \u7684\u4f7f\u7528<br \/>\n<\/h2>\n<p>\n\t\u5b89\u88c5\u5b8c\u6210 GoAccess \u540e\uff0c\u4f7f\u7528\u5b83\u5c31\u53d8\u5f97\u5f88\u7b80\u5355\u3002\n<\/p>\n<pre class=\"brush:bash;\">\r\ngoaccess xttblog.access.log -o ..\/html\/report.html --real-time-html --time-format=&#039;%H:%M:%S&#039; --date-format=&#039;%d\/%b\/%y&#039; --log-format=COMBINED<\/pre>\n<p>\n\t\u6267\u884c\u4e0a\u9762\u8fd9\u4e2a\u6307\u4ee4\uff0c\u5c31\u5f00\u542f\u4e86 GoAccess\u3002\u5176\u4e2d xttblog.access.log \u662f\u6211\u7684\u65e5\u5fd7\u4f4d\u7f6e\uff0c\u65e5\u5fd7\u6587\u4ef6\u540d\u3002-o ..\/html\/report.html \u662f\u5c06\u65e5\u5fd7\u6587\u4ef6\u8f93\u51fa\u5230\u8fd9\u4e2a html \u6587\u4ef6\u4e2d\u3002&#8211;real-time-html \u5c31\u662f\u5b9e\u65f6\u7684\u8f93\u51fa\u5230 html \u6587\u4ef6\u3002&#8211;time-format \u4ee3\u8868\u65f6\u95f4\u683c\u5f0f\u3002&#8211;date-format \u65e5\u671f\u683c\u5f0f\u3002&#8211;log-format \u65e5\u5fd7\u683c\u5f0f\u3002\n<\/p>\n<p>\n\t\u5176\u4e2d\uff0c\u65e5\u5fd7\u683c\u5f0f\u5171\u6709 10 \u79cd\uff1a\n<\/p>\n<ul>\n<li>\n\t\tCOMBINED &nbsp; &nbsp; | \u8054\u5408\u65e5\u5fd7\u683c\u5f0f\n\t<\/li>\n<li>\n\t\tVCOMBINED &nbsp; &nbsp;| \u652f\u6301\u865a\u62df\u4e3b\u673a\u7684\u8054\u5408\u65e5\u5fd7\u683c\u5f0f\n\t<\/li>\n<li>\n\t\tCOMMON &nbsp; &nbsp; &nbsp; | \u901a\u7528\u65e5\u5fd7\u683c\u5f0f\n\t<\/li>\n<li>\n\t\tVCOMMON &nbsp; &nbsp; &nbsp;| \u652f\u6301\u865a\u62df\u4e3b\u673a\u7684\u901a\u7528\u65e5\u5fd7\u683c\u5f0f\n\t<\/li>\n<li>\n\t\tW3C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| W3C \u6269\u5c55\u65e5\u5fd7\u683c\u5f0f\n\t<\/li>\n<li>\n\t\tSQUID &nbsp; &nbsp; &nbsp; &nbsp;| Native Squid \u65e5\u5fd7\u683c\u5f0f\n\t<\/li>\n<li>\n\t\tCLOUDFRONT &nbsp; | \u4e9a\u9a6c\u900a CloudFront Web \u5206\u5e03\u5f0f\u7cfb\u7edf\n\t<\/li>\n<li>\n\t\tCLOUDSTORAGE | \u8c37\u6b4c\u4e91\u5b58\u50a8\n\t<\/li>\n<li>\n\t\tAWSELB &nbsp; &nbsp; &nbsp; | \u4e9a\u9a6c\u900a\u5f39\u6027\u8d1f\u8f7d\u5747\u8861\n\t<\/li>\n<li>\n\t\tAWSS3 &nbsp; &nbsp; &nbsp; &nbsp;| \u4e9a\u9a6c\u900a\u7b80\u5355\u5b58\u50a8\u670d\u52a1 (S3)\n\t<\/li>\n<\/ul>\n<p>\n\t\u65e5\u5fd7\/\u65e5\u671f\/\u65f6\u95f4 \u683c\u5f0f\u8bf4\u660e\u5982\u4e0b\uff1a\n<\/p>\n<ul>\n<li>\n\t\t&#8211;time-format &lt;timeformat&gt;\uff1a\u53c2\u6570 time-format \u540e\u8ddf\u968f\u4e00\u4e2a\u7a7a\u683c\u7b26\uff0c\u6307\u5b9a\u65e5\u5fd7\u7684\u65f6\u95f4\u683c\u5f0f\uff0c\u5305\u542b\u666e\u901a\u5b57\u7b26\u4e0e\u7279\u6b8a\u683c\u5f0f\u8bf4\u660e\u7b26\u7684\u4efb\u610f\u7ec4\u5408\u3002\u4ed6\u4eec\u90fd\u7531\u767e\u5206\u53f7 (%)\u5f00\u59cb\u3002\u53c2\u8003 `man strftime`\u3002 %T \u6216\u8005 %H:%M:%S.\n\t<\/li>\n<li>\n\t\t&#8211;date-format &lt;dateformat&gt;\uff1a\u53c2\u6570 date-format \u540e\u8ddf\u968f\u4e00\u4e2a\u7a7a\u683c\u7b26\uff0c\u6307\u5b9a\u65e5\u5fd7\u7684\u65e5\u671f\u683c\u5f0f\uff0c\u5305\u542b\u666e\u901a\u5b57\u7b26\u4e0e\u7279\u6b8a\u683c\u5f0f\u8bf4\u660e\u7b26\u7684\u4efb\u610f\u7ec4\u5408\u3002\u4ed6\u4eec\u90fd\u7531\u767e\u5206\u53f7 (%)\u5f00\u59cb\u3002\u53c2\u8003 `man strftime`\u3002\n\t<\/li>\n<li>\n\t\t&#8211;log-format &lt;logformat&gt;\uff1a\u53c2\u6570 log-format \u540e\u8ddf\u968f\u4e00\u4e2a\u7a7a\u683c\u7b26\u6216\u8005\u5236\u8868\u5206\u9694\u7b26(\\t)\uff0c\u7528\u4e8e\u6307\u5b9a\u65e5\u5fd7\u5b57\u7b26\u4e32\u683c\u5f0f\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u7136\u540e\uff0c\u6211\u4eec\u518d\u5728 nginx \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u52a0\u5165\u4e0b\u9762\u7684\u4e00\u6bb5\u914d\u7f6e\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\nlocation \/report.html {\r\n  alias \/usr\/local\/openresty\/nginx\/html\/report.html;\r\n}<\/pre>\n<p>\n\t\u7136\u540e\uff0c\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u540e\uff0c\u8bbf\u95ee report.html \u5373\u53ef\u67e5\u770b\u5230 nginx \u7684 access \u65e5\u5fd7\u6587\u4ef6\u8be6\u60c5\u5e76\u76d1\u63a7\u5b83\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3969\">GoAccess \u5b9e\u73b0 Nginx access \u65e5\u5fd7\u53ef\u89c6\u5316\u663e\u793a\u548c\u5b9e\u65f6\u76d1\u63a7<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5f00\u53d1\u4e00\u4e2a\u7cfb\u7edf\uff0c\u5927\u5bb6\u7b2c\u4e00\u65f6\u95f4\u5e94\u8be5\u60f3\u5230\u7684\u5c31\u662f\u65e5\u5fd7\u3002\u8fd9\u4e5f\u662f\u5f88\u591a\u67b6\u6784\u5e08\u8981\u8003\u8651\u7684\u4e8b\u60c5\u3002 \u6bd4\u5982\uff0c\u6211\u6709\u4e0a\u4e07\u53f0\u673a\u5668\u7684\u8bdd\uff0c\u6bcf\u53f0\u673a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118,6],"tags":[1827,1942,1152,313,1154],"class_list":["post-3969","post","type-post","status-publish","format-standard","hentry","category-ndisdevelop","category-yyzt","tag-access_log","tag-goaccess","tag-nginx","tag-nginx-tfs"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3969"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3969\/revisions"}],"predecessor-version":[{"id":3970,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3969\/revisions\/3970"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}