{"id":1980,"date":"2016-09-18T15:57:48","date_gmt":"2016-09-18T07:57:48","guid":{"rendered":"https:\/\/www.ookangzheng.com\/?p=1980"},"modified":"2020-05-24T15:59:44","modified_gmt":"2020-05-24T07:59:44","slug":"password-protect-for-nginx-directory","status":"publish","type":"post","link":"https:\/\/www.ookangzheng.com\/password-protect-for-nginx-directory\/","title":{"rendered":"Password protect for Nginx directory"},"content":{"rendered":"

Create a htpasswd file inside your website directory you wish to protect (xxx.com\/htpasswd)<\/p>\n

Password must be\u00a0encoded by the crypt(3) function if Apache is not installed<\/p>\n

I suggest you to use this tools to generate it\u00a0http:\/\/www.tools.dynamicdrive.com\/password\/<\/a><\/p>\n

Config your nginx vhost\u00a0conf file<\/p>\n

<\/code>location \/ { <\/code><\/p>\n

auth_basic \"Restricted Area\"; <\/code><\/p>\n

auth_basic_user_file \/home\/wwwroot\/xxx.com\/htpasswd; }<\/code><\/p>\n

Restart your nginx service, Done !!<\/p>\n

\"2016-09-18_15-53-54\" \"2016-09-18_15-54-02\"<\/p>\n","protected":false},"excerpt":{"rendered":"

Create a htpasswd file inside your website directory you wish to protect (xxx.com\/htpasswd) Password must be\u00a0encoded by the crypt(3) function…<\/p>\n","protected":false},"author":1,"featured_media":1983,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,32],"tags":[74,83],"class_list":["post-1980","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-technology","tag-linux","tag-nginx"],"_links":{"self":[{"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/posts\/1980","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/comments?post=1980"}],"version-history":[{"count":0,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/posts\/1980\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/media\/1983"}],"wp:attachment":[{"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/media?parent=1980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/categories?post=1980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ookangzheng.com\/wp-json\/wp\/v2\/tags?post=1980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}