{"id":5425,"date":"2021-01-04T11:30:43","date_gmt":"2021-01-04T11:30:43","guid":{"rendered":"https:\/\/blog.gwlin.com\/?p=5425"},"modified":"2023-04-01T00:30:55","modified_gmt":"2023-04-01T00:30:55","slug":"nginx \u6dfb\u52a0 http \u8ba4\u8bc1","status":"publish","type":"post","link":"https:\/\/www.gwlin.com\/blog\/posts\/5425","title":{"rendered":"nginx \u6dfb\u52a0 http \u8ba4\u8bc1"},"content":{"rendered":"\n<p>\u6709\u65f6\u5019\u6211\u4eec\u5e0c\u671b\u81ea\u5df1\u7684\u4e00\u4e2a\u7ad9\u70b9\u9700\u8981\u8ba4\u8bc1\u624d\u53ef\u4ee5\u8bbf\u95ee\uff0c\u4f8b\u5982\u6211\u81ea\u5df1\u7684\u670d\u52a1\u5668\u76d1\u63a7netdata\uff0c\u5c31\u4e0d\u5e0c\u671b\u6bcf\u4e2a\u4eba\u90fd\u53ef\u4ee5\u6253\u5f00\uff0c\u8fd9\u4e2a\u65f6\u5019 http authentication \u5c31\u6d3e\u4e0a\u7528\u573a\u4e86\u3002\u4e0b\u9762\u4ee5\u81ea\u5df1\u7684ubuntu18.04+nginx\u4e3a\u4f8b\u3002 \u57fa\u672c\u8fc7\u7a0b\u662f\uff1a<\/p>\n\n\n\n<p> 1\u3001\u5b89\u88c5 apache2-utils\uff0c\u7528\u6765\u751f\u6210\u8d26\u53f7\u5bc6\u7801\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n\n\n\n<p> 2\u3001nginx\u5f15\u7528\u751f\u6210\u597d\u7684\u8d26\u53f7\u5bc6\u7801\u6587\u4ef6\u5b9e\u73b0\u6388\u6743\u8bbf\u95ee\u3002 <\/p>\n\n\n\n<p>\u5b9e\u9645\u8fc7\u7a0b\uff1a<\/p>\n\n\n\n<p> 1\u3001\u5b89\u88c5 apache2-utils<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\"  class=\"\">sudo apt install apache2-utils<\/code><\/pre>\n\n\n\n<p>2\u3001\u751f\u6210\u914d\u7f6e <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\"  class=\"\">sudo htpasswd -c \/etc\/nginx\/.htpasswd xxx #xxx\u4e3a\u7528\u6237\u540d<\/code><\/pre>\n\n\n\n<p>\u8fd0\u884c\u4e4b\u540e\u4f1a\u63d0\u793a\u8f93\u5165\u4e24\u6b21\u5bc6\u7801\u3002\u540c\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u53ef\u4ee5\u5b58\u653e\u591a\u4e2a\u8d26\u53f7\u7684\u3002 <\/p>\n\n\n\n<p>3\u3001\u914d\u7f6enginx <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\"  class=\"\">server {\n    # ...\n    location \/ {\n        # ...\n        auth_basic &quot;Private Property&quot;;\n        auth_basic_user_file \/etc\/nginx\/.htpasswd; # \u521a\u521a\u751f\u6210\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u8def\u5f84\u5176\u5b9e\u53ef\u4ee5\u6309\u7167\u81ea\u5df1\u7684\u9700\u8981\u4fee\u6539\u7684\n        # ...\n    }\n    # ...\n}<\/code><\/pre>\n\n\n\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u65f6\u5019\u6211\u4eec\u5e0c\u671b\u81ea\u5df1\u7684\u4e00\u4e2a\u7ad9\u70b9\u9700\u8981\u8ba4\u8bc1\u624d\u53ef\u4ee5\u8bbf\u95ee\uff0c\u4f8b\u5982\u6211\u81ea\u5df1\u7684\u670d\u52a1\u5668\u76d1\u63a7netdata\uff0c\u5c31\u4e0d\u5e0c\u671b\u6bcf\u4e2a\u4eba\u90fd\u53ef\u4ee5\u6253\u5f00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[179],"tags":[],"class_list":["post-5425","post","type-post","status-publish","format-standard","hentry","category-notes"],"_links":{"self":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/5425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/comments?post=5425"}],"version-history":[{"count":0,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/5425\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/media?parent=5425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/categories?post=5425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/tags?post=5425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}