×ðÁú¿­Ê±¹ÙÍøµÇ¼

NginxÔõÑùʵÏÖ»ùÓÚÓû§ÈÏÖ¤µÄ»á¼û¿ØÖÆÉèÖÃ

NginxÔõÑùʵÏÖ»ùÓÚÓû§ÈÏÖ¤µÄ»á¼û¿ØÖÆÉèÖà £¬ÐèÒªÏêϸ´úÂëʾÀý

NginxÊÇÒ»¿î¸ßÐÔÄܵÄWebЧÀÍÆ÷Èí¼þ £¬³ýÁ˳£¼ûµÄ¾²Ì¬ÎļþЧÀͺͷ´ÏòÊðÀí¹¦Ð§Íâ £¬Nginx»¹ÌṩÁËÐí¶àÇ¿Ê¢µÄ¹¦Ð§ £¬ÈçÓû§ÈÏÖ¤¡¢»á¼û¿ØÖƵÈ¡£ÔÚ±¾ÎÄÖÐ £¬½«ÏÈÈÝÔõÑùʹÓÃNginxʵÏÖ»ùÓÚÓû§ÈÏÖ¤µÄ»á¼û¿ØÖÆÉèÖà £¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚNginxµÄÉèÖÃÎļþÖÐÌí¼ÓÒÔÏ´úÂëÀ´ÆôÓûùÓÚÓû§ÈÏÖ¤µÄ¹¦Ð§£º

location / {
    auth_basic           "Restricted";                      # ÆôÓûùÓÚÓû§ÈÏÖ¤µÄ»á¼û¿ØÖÆ
    auth_basic_user_file /etc/nginx/.htpasswd;              # Ö¸¶¨ÉúÑÄÓû§ÈÏÖ¤ÐÅÏ¢µÄÎļþ·¾¶
    try_files            $uri $uri/ /index.php?$query_string; # ÆäËûÐèÒª´¦ÀíµÄÇëÇó
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëÖÐ £¬auth_basicÌåÏÖÆôÓûùÓÚÓû§ÈÏÖ¤µÄ¹¦Ð§ £¬²¢ÉèÖÃÁËÒ»¸öÈÏÖ¤ÌáÐÑÐÅÏ¢”Restricted”¡£ auth_basic_user_fileÖ¸¶¨ÁËÉúÑÄÓû§ÈÏÖ¤ÐÅÏ¢µÄÎļþ·¾¶ £¬Õâ¸öÎļþ¿ÉÒÔʹÓÃhtpasswd¹¤¾ßÀ´ÌìÉú¡£

½ÓÏÂÀ´ £¬ÎÒÃÇÐèҪʹÓÃhtpasswd¹¤¾ßÌìÉúÓû§ÈÏÖ¤ÐÅÏ¢Îļþ¡£ÔÚÖÕ¶ËÖÐÔËÐÐÒÔÏÂÏÂÁ

$ htpasswd -c /etc/nginx/.htpasswd username

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄÏÂÁîÖÐ £¬-cÌåÏÖ½¨ÉèÒ»¸öеÄÎļþ £¬/etc/nginx/.htpasswdÊÇÉúÑÄÓû§ÈÏÖ¤ÐÅÏ¢µÄÎļþ·¾¶ £¬usernameÊÇÐèÒªÌí¼Óµ½ÈÏÖ¤ÎļþÖеÄÓû§Ãû¡£Ö´ÐÐÉÏÊöÏÂÁîºó £¬½«»áÈÃÄãÉèÖÃÃÜÂë¡£

ÏÖÔÚ £¬ÎÒÃÇÀ´½¨ÉèÒ»¸ö¼òÆÓµÄʾÀýÀ´²âÊÔ»ùÓÚÓû§ÈÏÖ¤µÄ»á¼û¿ØÖÆ¡£

¼ÙÉèÎÒÃÇÓÐÒ»¸öÍøÕ¾ £¬ÆäÖÐÖ»Óо­ÓÉÈÏÖ¤µÄÓû§²Å»ª»á¼û/adminĿ¼¡£ÔÚNginxµÄÉèÖÃÎļþÖÐÌí¼ÓÒÔÏ´úÂ룺

location /admin/ {
    auth_basic           "Restricted";                      # ÆôÓûùÓÚÓû§ÈÏÖ¤µÄ»á¼û¿ØÖÆ
    auth_basic_user_file /etc/nginx/.htpasswd;              # Ö¸¶¨ÉúÑÄÓû§ÈÏÖ¤ÐÅÏ¢µÄÎļþ·¾¶
    try_files            $uri $uri/ /index.php?$query_string; # ÆäËûÐèÒª´¦ÀíµÄÇëÇó
}

µÇ¼ºó¸´ÖÆ

ÉúÑÄÉèÖÃÎļþ²¢ÖØмÓÔØNginxЧÀÍ¡£È»ºó £¬ÊµÑé»á¼û/adminĿ¼ £¬Ä㽫»á±»ÒªÇóÊäÈëÓû§ÃûºÍÃÜÂë¡£

ÒÔÉϾÍÊÇʹÓÃNginxʵÏÖ»ùÓÚÓû§ÈÏÖ¤µÄ»á¼û¿ØÖÆÉèÖõÄÏêϸ°ì·¨ºÍʾÀý´úÂ롣ͨ¹ýʹÓÃÕâЩ¹¦Ð§ £¬¿ÉÒÔÓÐÓõر£»¤ÄãµÄÍøÕ¾²»±»Î´¾­ÊÚȨµÄÓû§»á¼û¡£Çë¼Ç×Å £¬ÎªÁË°ü¹ÜÇå¾²ÐÔ £¬Ó¦¸Ã°´ÆÚ¸ü¸ÄÓû§ÈÏÖ¤ÐÅÏ¢ £¬²¢ÏÞÖƶÔÉúÑÄÓû§ÈÏÖ¤ÐÅÏ¢µÄÎļþµÄ»á¼ûȨÏÞ¡£

ÒÔÉϾÍÊÇNginxÔõÑùʵÏÖ»ùÓÚÓû§ÈÏÖ¤µÄ»á¼û¿ØÖÆÉèÖõÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ