{"id":180,"date":"2018-06-10T18:09:58","date_gmt":"2018-06-10T09:09:58","guid":{"rendered":"https:\/\/blog.kifuyu.net\/?p=180"},"modified":"2018-06-16T06:59:44","modified_gmt":"2018-06-15T21:59:44","slug":"nginx%e3%81%a7basic%e8%aa%8d%e8%a8%bc%e3%81%8b%e3%81%91%e3%82%8b%e3%81%a8404%e3%81%ab%e3%81%aa%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.kifuyu.net\/?p=180","title":{"rendered":"nginx\u3067Basic\u8a8d\u8a3c\u304b\u3051\u308b\u3068404\u306b\u306a\u308b"},"content":{"rendered":"<p>kifuyu.net\u306b\u975e\u516c\u958b\u306e\u30da\u30fc\u30b8\u3092\u4f5c\u308a\u305f\u304f\u3066Basic\u8a8d\u8a3c\u3092\u5c0e\u5165\u3057\u307e\u3057\u305f\u3002<br \/>\nNginx\u3067Basic\u8a8d\u8a3c\u3092\u884c\u3046\u305f\u3081\u306b\u306fApache\u3067\u3044\u3046.htaccess\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8db3\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306fBasic\u8a8d\u8a3c\u5c0e\u5165\u5f8c\u306b404\u304c\u9023\u767a\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u305d\u306e\u5bfe\u51e6\u306e\u30e1\u30e2\u66f8\u304d\u3067\u3059\u3002<\/p>\n<p>\u25b6\u4efb\u610f\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bBasic\u8a8d\u8a3c\u3092\u304b\u3051\u308b<br \/>\n\u25b6location\u306e\u8a18\u8ff0\u4f4d\u7f6e\u3092\u8aa4\u308b\u3068404<\/p>\n<p>\u30fb\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u5c0e\u5165<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ sudo yum install -y httpd-tools\r\n$ sudo htpasswd -c \/etc\/nginx\/conf.d\/.htpasswd &lt;userName&gt;\r\n<\/pre>\n<p>\u3053\u3053\u307e\u3067\u3067\/etc\/nginx\/conf.d\/.htpasswd\u306b &lt;userName&gt;\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u751f\u6210\u3055\u308c\u3066\u307e\u3059\u3002<br \/>\nhtpasswd\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092-c\u304b\u3089-m\u306b\u3059\u308b\u3068MD5\u3067\u30cf\u30c3\u30b7\u30e5\u3055\u308c\u307e\u3059\u3002\u6c17\u306b\u306a\u308b\u4eba\u306f\u5f8c\u8005\u306e\u65b9\u304c\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\uff4e\u3002<br \/>\n\u3068\u3053\u308d\u3067Nginx\u3067\u306f\u8a2d\u5b9a\u3092\u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306binclude\u3067\u304d\u308b\u306e\u3067\u3001\u79c1\u306fconf.d\u3068\u3044\u3046\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u3063\u3066conf\u30d5\u30a1\u30a4\u30eb\u3092\u5206\u5272\u3057\u3066\u683c\u7d0d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30fbNginx\u306econf\u30d5\u30a1\u30a4\u30eb\u306e\u8a2d\u5b9a\u3092\u884c\u3046<\/p>\n<p><code>$ vi \/etc\/nginx\/conf.d\/&lt;http\u306e\u8a2d\u5b9a\u304c\u66f8\u304b\u308c\u305fconf\u30d5\u30a1\u30a4\u30eb&gt;.conf<\/code><\/p>\n<p>\u3042\u308b\u4efb\u610f\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea &#8220;nyan&#8221;\u306bBasic\u8a8d\u8a3c\u3092\u304b\u3051\u307e\u3059<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nserver {\r\nlocation \/ { ....\r\n    location \/nyan\/ {\r\n            auth_basic &quot;Auth&quot;;\r\n            auth_basic_user_file \/etc\/nginx\/conf.d\/.htpasswd;\r\n    } #location \/nayn\u306e\u7d42\r\n} #location \/ \u306e\u7d42<\/pre>\n<p>\u6ce8\u610f\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea&#8221;nyan&#8221;\u306elocation\u8a2d\u5b9a\u304cRoot\u4ee5\u4e0b\u306elocation\u8a2d\u5b9a\u5185\u306b\u66f8\u304b\u308c\u3066\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3053\u3068\u3067\u3059\u3002<br \/>\n\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u8aad\u307e\u305alocation\u3054\u3068\u306b\u4e2d\u62ec\u5f27\u3092\u3064\u3051\u3066\u3044\u305f\u306e\u3067404\u9023\u767a\u3067\u3057\u305f\u3002<\/p>\n<p>\u3057\u3063\u304b\u3057\u5e73\u6587\u3067\u30d1\u30b9\u30ef\u30fc\u30c9\u3084\u308a\u3068\u308a\u3059\u308b\u306e\u306f\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>kifuyu.net\u306b\u975e\u516c\u958b\u306e\u30da\u30fc\u30b8\u3092\u4f5c\u308a\u305f\u304f\u3066Basic\u8a8d\u8a3c\u3092\u5c0e\u5165\u3057\u307e\u3057\u305f\u3002 Nginx\u3067Basic\u8a8d\u8a3c\u3092\u884c\u3046\u305f\u3081\u306b\u306fApache\u3067\u3044\u3046.htaccess\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8db3\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u4eca\u56de\u306fBasic\u8a8d\u8a3c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[14,3],"tags":[],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-14","category-3","ja"],"_links":{"self":[{"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180"}],"version-history":[{"count":0,"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kifuyu.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}