{"id":1349,"date":"2021-08-29T16:32:59","date_gmt":"2021-08-29T08:32:59","guid":{"rendered":"https:\/\/www.siediyer.cn\/?p=1349"},"modified":"2021-08-29T16:32:59","modified_gmt":"2021-08-29T08:32:59","slug":"nginx-%e6%b7%bb%e5%8a%a0%e7%94%a8%e6%88%b7%e8%ae%a4%e8%af%81","status":"publish","type":"post","link":"https:\/\/www.siediyer.cn\/?p=1349","title":{"rendered":"nginx \u6dfb\u52a0\u7528\u6237\u8ba4\u8bc1"},"content":{"rendered":"<p>\u914d\u7f6e\u4ee3\u7406\u6dfb\u52a0\u7528\u6237\u8ba4\u8bc1\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\r\nserver {\r\n\u00a0 listen \u00a0 \u00a0 \u00a0 80;\r\n\u00a0 server_name localhost;\r\n\u00a0 location \/ {\r\n\u00a0 \u00a0 \u00a0auth_basic \"secret\";\r\n\u00a0 \u00a0 \u00a0auth_basic_user_file \/etc\/nginx\/conf.d\/passwd.db;\r\n\u00a0 \u00a0 \u00a0proxy_pass http:\/\/localhost:2018;\r\n\u00a0 \u00a0 \u00a0proxy_set_header Host $host:2018;\r\n\u00a0 \u00a0 \u00a0proxy_set_header X-Real-IP $remote_addr;\r\n\u00a0 \u00a0 \u00a0proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n\u00a0 \u00a0 \u00a0proxy_set_header Via \"nginx\";\r\n\u00a0 }\r\n}<\/pre>\n<p><strong>\u5b89\u88c5 http \u63d2\u4ef6\uff1a<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">yum install http -y<\/pre>\n<p><strong>\u6dfb\u52a0\u8d26\u6237\u5bc6\u7801\uff1a\uff08\u8d26\u6237\u5bc6\u7801\u6587\u4ef6\u4f1a\u5b58\u5728\u521a\u624d\u914d\u7f6e\u7684\u00a0\/etc\/nginx\/conf.d\/passwd.db \u4e2d\uff09<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># htpasswd -b \/etc\/nginx\/conf.d\/passwd.db user1 passwd1\r\n# htpasswd -b \/etc\/nginx\/conf.d\/passwd.db user2 passwd2<\/pre>\n<p><strong>\u6d4b\u8bd5 http:\/\/ip\/ \u4f1a\u6709\u63d0\u793a\u6846 \u8f93\u5165\u8d26\u6237\u5bc6\u7801<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u914d\u7f6e\u4ee3\u7406\u6dfb\u52a0\u7528\u6237\u8ba4\u8bc1\uff1a server { \u00a0 listen \u00a0 \u00a0 \u00a0 80; \u00a0 server_name l [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1349","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1349"}],"version-history":[{"count":1,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1349\/revisions"}],"predecessor-version":[{"id":1350,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/1349\/revisions\/1350"}],"wp:attachment":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}