{"id":1701,"date":"2017-09-24T18:07:25","date_gmt":"2017-09-24T10:07:25","guid":{"rendered":"https:\/\/zoco.me\/?p=15"},"modified":"2017-09-24T18:07:25","modified_gmt":"2017-09-24T10:07:25","slug":"nginx-proxy-google-analytics-conf","status":"publish","type":"post","link":"https:\/\/cloudbool.com\/archive\/nginx-proxy-google-analytics-conf.html","title":{"rendered":"Nginx\u53cd\u4ee3Google Analytics\u914d\u7f6e"},"content":{"rendered":"<p>\u867d\u7136\u6ca1\u51e0\u4e2a\u4eba\u8bbf\u95ee\uff0c\u4f46\u662f\u6211\u8fd8\u662f\u7ed9\u8fd9\u5c0f\u535a\u5ba2\u4e0a\u4e86Google Analytics\uff0c\u6ca1\u6709\u522b\u7684\uff0c\u5c31\u662f\u60f3\u4e86\u89e3\u4e0b\u5927\u6982\u6709\u51e0\u4e2a\u4eba\u4f1a\u8bbf\u95ee\uff0c\u5e76\u4e86\u89e3\u4e0b\u662f\u901a\u8fc7\u90a3\u4e9b\u5173\u952e\u5b57\u8fdb\u6765\u7684\u3002<\/p>\n<p>\u4f46\u662f\u76f4\u63a5\u9ecf\u8d34Google\u7ed9\u7684\u4ee3\u7801\u4e4b\u540e\uff0c\u76f8\u5173\u4ee3\u7801\u4e25\u91cd\u62d6\u6162\u8bbf\u95ee\u901f\u5ea6\uff0c\u6d4f\u89c8\u5668\u4e00\u76f4\u5728\u8f6c\u554a\u8f6c\u7684\uff0c\u7528Google Chrome\u7684\u5f00\u53d1\u8005\u5de5\u5177\u67e5\u770b\u53d1\u73b0\uff0c\u5c31\u662f\u52a0\u8f7dGA\u4ee3\u7801\u5bfc\u81f4\u7684\uff0c\u4e8e\u662f\u6253\u7b97\u901a\u8fc7Nginx\u53bbGoogle\u52a0\u8f7d\u76f8\u5173\u4ee3\u7801\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u4e0d\u591a\u8bf4\uff0c\u76f4\u63a5\u4e0a\u4ee3\u7801\uff1a<\/p>\n<pre class=\"line-numbers prism-highlight\" data-start=\"1\"><code class=\"language-null\">location \/analytics.js {\n    proxy_pass https:\/\/www.google-analytics.com;\n    proxy_hide_header Strict-Transport-Security;\n}\n<\/code><\/pre>\n<p>\u5230\u76f8\u5173\u7f51\u7ad9\u7684server\u6bb5\u5185\u52a0\u4e0a\u4e0a\u9762\u8fd9\u884c\u5c31\u884c\u4e86\uff0c\u91cd\u542fNginx\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u901a\u8fc7\u57df\u540d\u52a0\u4e0a<strong><em>\/analytics.js<\/em><\/strong>\u8bbf\u95eeGA\u7684JS\u4ee3\u7801\u4e86\uff0c\u6bd4\u5982\u6211\u7684\u5c31\u662f\uff1a<br \/>\nhttps:\/\/zoco.me\/analytics.js<br \/>\n\u7136\u540e\u5c06Google\u7ed9\u7684\u4ee3\u7801\u91cc\u9762\u7684\u57df\u540d\u6539\u6210\u7f51\u7ad9\u57df\u540d\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre class=\"line-numbers prism-highlight\" data-start=\"1\"><code class=\"language-null\">&lt;script&gt;\n(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,'script','https:\/\/ar.zoco.me\/analytics.js','ga');\nga('create', 'UA-97021222-1', 'auto');\nga('send', 'pageview');\n&lt;\/script&gt;\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u5230\u6a21\u677f\u6587\u4ef6\u4e4b\u540e\uff0c\u91cd\u65b0\u6253\u5f00\u5c31\u884c\u3002<\/p>\n<hr>\n<p>\u8fd9\u91cc\u6709\u4e00\u70b9\u7279\u522b\u8981\u8bf4\u660e\u7684\uff0c\u4e0a\u9762Nginx\u914d\u7f6e\u4e2d\u6709\u4e00\u884c<strong><em>proxy_hide_header<\/em><\/strong>\uff0c\u8fd9\u4e00\u884c\u5efa\u8bae\u52a0\u4e0a\uff0c\u53ef\u80fd\u662f\u56e0\u4e3aGA\u4f7f\u7528\u4e86HSTS\uff0c\u5982\u679c\u4e0d\u52a0\u4e0a\u8fd9\u884c\uff0c\u5728\u6d4f\u89c8\u5668\u52a0\u8f7d\u672c\u5730\u57df\u540d\u4e0b\u7684JS\u6587\u4ef6\u65f6\uff0c\u4f1a\u628a\u672c\u5730\u57df\u540d\u4e5f\u52a0\u4e0aHSTS\uff0c\u8fd9\u6837\u4f1a\u5bfc\u81f4\u5f53\u524d\u57df\u540d\u6240\u6709\u5b50\u57df\u540d\u5728\u4e00\u4e9b\u65b0\u7684\u6d4f\u89c8\u5668\u4e0b\u9ed8\u8ba4\u542f\u7528HTTPS\uff0c\u8fd9\u6837\u5373\u4f7f\u8f93\u5165HTTP\u524d\u7f00\u4e5f\u4f1a\u81ea\u52a8\u91cd\u5b9a\u5411\u5230HTTPS\uff0c\u5982\u679c\u6709\u4e9b\u5b50\u57df\u540d\u6ca1\u6709\u914d\u7f6eHTTPS\u5219\u65e0\u6cd5\u6253\u5f00\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u867d\u7136\u6ca1\u51e0\u4e2a\u4eba\u8bbf\u95ee\uff0c\u4f46\u662f\u6211\u8fd8\u662f\u7ed9\u8fd9\u5c0f\u535a\u5ba2\u4e0a\u4e86Google Analytics\uff0c\u6ca1\u6709\u522b\u7684\uff0c\u5c31\u662f\u60f3\u4e86\u89e3\u4e0b\u5927\u6982\u6709\u51e0\u4e2a\u4eba &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/cloudbool.com\/archive\/nginx-proxy-google-analytics-conf.html\"> <span class=\"screen-reader-text\">Nginx\u53cd\u4ee3Google Analytics\u914d\u7f6e<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[76],"class_list":["post-1701","post","type-post","status-publish","format-standard","hentry","category-tech","tag-nginx"],"_links":{"self":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/comments?post=1701"}],"version-history":[{"count":0,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1701\/revisions"}],"wp:attachment":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/media?parent=1701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/categories?post=1701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/tags?post=1701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}