{"id":1229,"date":"2011-07-30T00:25:33","date_gmt":"2011-07-29T16:25:33","guid":{"rendered":"http:\/\/www.jpuyy.com\/blog\/?p=1229"},"modified":"2014-01-14T19:19:53","modified_gmt":"2014-01-14T11:19:53","slug":"nginx-http-basic-pass","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=1229","title":{"rendered":"nginx\u5bf9\u67d0\u76ee\u5f55\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1"},"content":{"rendered":"<p>\u672c\u4f8b\u5bf9web\u6839\u76ee\u5f55\u4e0b\u7684phpmyadmin\u6587\u4ef6\u5939\u8fdb\u884c\u8ba4\u8bc1<\/p>\n<p>#cd \/usr\/local\/nginx\/conf<br \/>\n#mkdir htpasswd<\/p>\n<p>\u5728 nginx.conf \u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684 server \u6bb5\u4e2d \u6dfb\u52a0\u5f15\u7528:<br \/>\nlocation ^~ \/phpmyadmin\/ {<br \/>\nauth_basic &#8220;database-login&#8221;;<br \/>\nauth_basic_user_file \/usr\/local\/nginx\/conf\/htpasswd\/DBpass;<br \/>\n}<\/p>\n<p>\u518d\u5728 \u76f8\u5e94\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6DBpass<br \/>\n\u6b64\u6587\u4ef6\u7684\u4e66\u5199\u683c\u5f0f\u662f<br \/>\n\u7528\u6237\u540d:\u5bc6\u7801<br \/>\n\u7528\u6237\u540d \u81ea\u5df1\u968f\u610f\u8bbe\u7f6e \u65e0\u9700\u52a0\u5bc6<\/p>\n<p>\u5bc6\u7801\u5fc5\u987b\u4f7f\u7528\u51fd\u6570 crypt(3) \u52a0\u5bc6<\/p>\n<p>\u65b9\u6cd5\u4e00\uff1a<\/p>\n<p>\u7528 htpasswd \u5de5\u5177\u6765\u521b\u5efa\u5bc6\u7801\u6587\u4ef6<\/p>\n<p>\/usr\/bin\/htpasswd -c \/usr\/local\/nginx\/conf\/htpasswd\/DBpass jpuyy\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/-c\u00a0 Create a new file.\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6 \u6700\u540e\u8ddf\u4e0a\u7528\u6237\u540d<\/p>\n<p>New password:<br \/>\nRe-type new password:<br \/>\nAdding password for user jpuyy<\/p>\n<p>&nbsp;<\/p>\n<p>\u65b9\u6cd5\u4e8c\uff1a<\/p>\n<p>\u4f7f\u7528perl \u521b\u5efa\u5bc6\u7801\u6587\u4ef6<\/p>\n<p>\u65b0\u5efa \u4e00\u4e2a pw.pl \u6587\u4ef6<\/p>\n<pre>#!\/usr\/bin\/perl\r\n use strict;\r\n my $pw=$ARGV[0] ;\r\n print crypt($pw,$pw).\"\\n\";<\/pre>\n<p>\u7136\u540e\u6267\u884c\uff1a<br \/>\nchmod +x pw.pl<br \/>\n.\/pw.pl password<br \/>\npapAq5PwY\/QQM \u5c31\u662fpassword \u7684crypt()\u5bc6\u7801<br \/>\n\u5982\u679c \u4e0d\u7528<br \/>\n^~ \/phpmyadmin\/<br \/>\n\u800c\u7528<br \/>\n\/phpmyadmin<br \/>\n\u5c06\u53ea\u80fd\u5bf9\u76ee\u5f55\u8fdb\u884c\u9a8c\u8bc1 \u76f4\u63a5\u8bbf\u95ee\u5176\u4e0b\u7684\u6587\u4ef6 \u5c06\u4e0d\u4f1a\u5f39\u51fa\u767b\u5f55\u9a8c\u8bc1<\/p>\n<p>\u6628\u5929\u641e\u597d\u540e\u8349\u8349\u4e86\u4e8b<br \/>\n\u4eca\u5929\u53d1\u73b0\u8ba4\u8bc1\u540ephp\u6253\u4e0d\u5f00\uff0c\u51e0\u7ecf\u641c\u7d22\u8d44\u6599\uff0c\u5728location\u91cc\u8981\u52a0\u4e0afast-cgi\uff0c\u6ce8\u610f\u4e24\u4e2alocation\u5305\u542b\u5173\u7cfb<\/p>\n<pre>#\u5bf9phpmyadmin\u8fdb\u884c\u8ba4\u8bc1\r\nlocation ^~\/phpmyadmin\/ {\r\n   location ~ \\.php$ { \t\r\n\tfastcgi_pass   127.0.0.1:9000;\r\n\tfastcgi_index  index.php;\r\n\tfastcgi_param  SCRIPT_FILENAME  \/web\/$fastcgi_script_name;\r\n\tinclude        fastcgi_params;\r\n\t}\r\n\r\n\troot   \/web\/;\r\n\tindex  index.php;\r\n\tauth_basic \"database-login\";\r\n\tauth_basic_user_file \/usr\/local\/nginx\/conf\/htpasswd\/DBpass;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u4f8b\u5bf9web\u6839\u76ee\u5f55\u4e0b\u7684phpmyadmin\u6587\u4ef6\u5939\u8fdb\u884c\u8ba4\u8bc1 #cd \/usr\/local\/nginx\/conf #mkdir htpasswd \u5728 nginx.conf \u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684 server \u6bb5\u4e2d \u6dfb\u52a0\u5f15\u7528: location ^~ \/phpmyadmin\/ { auth_basic &#8220;database-login&#8221;; auth_basic_user_file \/usr\/local\/nginx\/conf\/htpasswd\/DBpass; } \u518d\u5728 \u76f8\u5e94\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6DBpass \u6b64\u6587\u4ef6\u7684\u4e66\u5199\u683c\u5f0f\u662f \u7528\u6237\u540d:\u5bc6\u7801 \u7528\u6237\u540d \u81ea\u5df1\u968f\u610f\u8bbe\u7f6e \u65e0\u9700\u52a0\u5bc6 \u5bc6\u7801\u5fc5\u987b\u4f7f\u7528\u51fd\u6570 crypt(3) \u52a0\u5bc6 \u65b9\u6cd5\u4e00\uff1a \u7528 htpasswd \u5de5\u5177\u6765\u521b\u5efa\u5bc6\u7801\u6587\u4ef6 \/usr\/bin\/htpasswd -c \/usr\/local\/nginx\/conf\/htpasswd\/DBpass jpuyy\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/-c\u00a0 Create a new file.\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6 \u6700\u540e\u8ddf\u4e0a\u7528\u6237\u540d New password: Re-type new password: Adding password for user jpuyy &nbsp; [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1229","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1229"}],"version-history":[{"count":24,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1229\/revisions"}],"predecessor-version":[{"id":6113,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1229\/revisions\/6113"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}