{"id":104072,"date":"2024-09-11T06:36:13","date_gmt":"2024-09-10T22:36:13","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=104072"},"modified":"2024-09-11T06:36:13","modified_gmt":"2024-09-10T22:36:13","slug":"nginx-password-authentication","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/nginx-password-authentication.html","title":{"rendered":"Nginx\u521b\u5efa\u5bc6\u7801\u9a8c\u8bc1\u4fdd\u62a4\u7f51\u7ad9\u76ee\u5f55\u5b89\u5168"},"content":{"rendered":"
\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u7f51\u7ad9\u9700\u8981\u6388\u6743\u8bbf\u95ee\u7684\u573a\u666f\u975e\u5e38\u4e4b\u591a\uff0c\u6bd4\u5982\u6570\u636e\u5e93\u7ba1\u7406\u5de5\u5177\uff1aphpMyAdmin\u3001MysqlUp\u3001BackUp\u7b49\u7b49\u3002\u6709\u65f6\u8fd8\u9700\u8981\u4e00\u4e9b\u79c1\u6709\u76ee\u5f55\u6587\u4ef6\u7684\u4fdd\u62a4\uff0c\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u4f1f\u5927\u76ee\u6807\uff0c\u6211\u4eec\u5c31\u9700\u8981\u7528\u5230Nginx location\u5339\u914d\u89c4\u5219\uff0c\u4e0b\u9762\u5c06\u8fdb\u884c\u8bb2\u89e3\u3002<\/p>\n
1.\u521b\u5efahtpasswd\u6587\u4ef6<\/p>\n
\r\n$ vim \/usr\/local\/nginx\/conf\/htpasswd\r\n\r\n\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a\r\n\r\nrenwole:xEmWnqjTJipoE\r\n\r\n\u6b64\u6587\u4ef6\u7684\u4e66\u5199\u683c\u5f0f\u662f\uff1a\r\n\r\n \u7528\u6237\u540d:\u5bc6\u7801\r\n\r\n\u6ce8\u610f\uff1a\u6bcf\u884c\u4e00\u4e2a\u7528\u6237\u548c\u5bc6\u7801\uff0c\u8fd9\u91cc\u7684password\u4e0d\u662f\u660e\u6587\uff0c\u800c\u662f\u5c06password\u8fdb\u884ccrypt(3)\u52a0\u5bc6\u540e\u7684\u5b57\u7b26\u4e32\u3002\r\n<\/pre>\n2.\u5bc6\u7801\u751f\u6210<\/p>\n
\u53ef\u4ee5\u6253\u5f00\u4ee5\u4e0b\u7f51\u5740\u8f93\u5165\u7528\u6237\u4fe1\u606f\u8fdb\u884c\u5bc6\u7801\u751f\u6210\uff1a<\/p>\n
http:\/\/tool.oschina.net\/htpasswd<\/p>\n
3.Nginx\u52a0\u5bc6\u76ee\u5f55\u914d\u7f6e<\/p>\n
\u5728Nginx\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u5408\u9002\u533a\u57df\u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n
\u5982\u679c\u4fdd\u62a4tools\u76ee\u5f55\uff1a<\/p>\n
\r\nlocation ^~ \/tools\/ {\r\nauth_basic \"Restricted Area\";\r\nauth_basic_user_file conf\/htpasswd;\r\n}\r\n<\/pre>\n\u8bf4\u660e\uff1a\u82e5\u4e0d\u52a0 ^~ \u53ea\u80fd\u5bf9\u76ee\u5f55\u8fdb\u884c\u5f39\u7a97\u9a8c\u8bc1\uff0c\u8bbf\u95ee\u6b64\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u5219\u65e0\u9700\u9a8c\u8bc1\u3002<\/p>\n
\u5982\u679c\u4fdd\u62a4\u6574\u4e2a\u7f51\u7ad9\u6839\u76ee\u5f55\uff1a<\/p>\n
\r\nlocation \/ {\r\nauth_basic \"Restricted Area\";\r\nauth_basic_user_file conf\/htpasswd;\r\n}\r\n<\/pre>\n\u6dfb\u52a0\u9700\u8981\u4fdd\u62a4\u7684\u76ee\u5f55\u540e\uff0c\u91cd\u8f7dNginx\u914d\u7f6e\u6587\u4ef6\uff0c\u5426\u5219\u4e0d\u751f\u6548\u3002<\/p>\n
\n\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/renwole.com\/archives\/963<\/a><\/p>\n