尊龙凯时人生就是博

Nginx»á¼û¿ØÖÆÉèÖà £¬ÏÞÖÆÖ¸¶¨Óû§»á¼û

nginx»á¼û¿ØÖÆÉèÖà £¬ÏÞÖÆÖ¸¶¨Óû§»á¼û

ÔÚWebЧÀÍÆ÷ÖÐ £¬»á¼û¿ØÖÆÊÇÒ»¸öÖ÷ÒªµÄÇå¾²²½·¥ £¬ÓÃÓÚÏÞÖÆÌض¨Óû§»òIPµØµãµÄ»á¼ûȨÏÞ¡£Nginx×÷Ϊһ¿î¸ßÐÔÄܵÄWebЧÀÍÆ÷ £¬Ò²ÌṩÁËÇ¿Ê¢µÄ»á¼û¿ØÖƹ¦Ð§¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNginxÉèÖÃÏÞÖÆÖ¸¶¨Óû§µÄ»á¼ûȨÏÞ £¬Í¬Ê±Ìṩ´úÂëʾÀý¹©²Î¿¼¡£

Ê×ÏÈ £¬ÎÒÃÇÐèҪ׼±¸Ò»¸ö»ù±¾µÄNginxÉèÖÃÎļþ¡£¼ÙÉèÎÒÃÇÒѾ­ÓÐÒ»¸öÍøÕ¾ £¬ÉèÖÃÎļþ·¾¶Îª/etc/nginx/nginx.conf¡£ÔÚ¸ÃÉèÖÃÎļþÖÐ £¬ÎÒÃǽ«Ìí¼ÓÒÔÏ»á¼û¿ØÖÆÉèÖãº

http {
  # ÆäËûÉèÖÃÄÚÈÝ...
  
  # ½ç˵һ¸öÑéÖ¤Îļþ£¬°üÀ¨ÔÊÐí»á¼ûµÄÓû§Ãû¼°ÃÜÂë
  auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
  
  # ½ç˵һ¸ölocation¿é£¬¶ÔÖ¸¶¨URL·¾¶¾ÙÐлá¼û¿ØÖÆ
  location /private {
    # ¿ªÆô»ùÓÚHTTP»ù±¾ÈÏÖ¤µÄ»á¼û¿ØÖÆ
    auth_basic "Restricted";
    
    # Ö¸¶¨Ö»¶ÔÌض¨Óû§Ãû¾ÙÐлá¼û¿ØÖÆ
    auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
    
    # ÆäËûÉèÖÃÄÚÈÝ...
  }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöÉèÖÃÖÐ £¬ÎÒÃÇʹÓÃÁËauth_basic_user_fileÖ¸Áî½ç˵ÁËÒ»¸öÑéÖ¤Îļþ £¬Ëü°üÀ¨ÁËÔÊÐí»á¼ûµÄÓû§Ãû¼°¶ÔÓ¦µÄÃÜÂë¡£Õâ¸öÑéÖ¤ÎļþµÄ·¾¶ÊÇ/etc/nginx/conf.d/.htpasswd £¬ÎÒÃÇ¿ÉÒÔƾ֤ÏÖʵÐèÒª¾ÙÐиü¸Ä¡£

½ÓÏÂÀ´ £¬ÎÒÃÇʹÓÃlocation¿é¶ÔÖ¸¶¨µÄURL·¾¶¾ÙÐлá¼û¿ØÖÆ¡£ÔÚʾÀýÖÐ £¬ÎÒÃÇʹÓÃÁË/private×÷Ϊ±»ÏÞÖÆ»á¼ûµÄ·¾¶ £¬Äú¿ÉÒÔƾ֤ÏÖÕæÏàÐξÙÐе÷½â¡£ÔÚ¸Ãlocation¿éÖÐ £¬ÎÒÃÇʹÓÃÁËauth_basicÖ¸ÁÆôÁË»ùÓÚHTTP»ù±¾ÈÏÖ¤µÄ»á¼û¿ØÖÆ¡£

ΪÁËÏÞÖÆÖ»ÓÐÌض¨Óû§¿ÉÒÔ»á¼û £¬ÎÒÃÇÔÙ´ÎʹÓÃÁËauth_basic_user_fileÖ¸Áî £¬²¢Ö¸¶¨ÁËÑéÖ¤ÎļþµÄ·¾¶¡£ÕâÑù £¬Ö»ÓÐÑéÖ¤ÎļþÖб£´æµÄÓû§Ãû²Å»ª»á¼û±»ÏÞÖƵÄURL·¾¶¡£

½ÓÏÂÀ´ £¬ÎÒÃÇÐèҪ׼±¸ÑéÖ¤Îļþ.htpasswd¡£Õâ¸öÎļþ¿ÉÒÔʹÓÃhtpasswdÏÂÁîÌìÉú £¬ËüÊÇApache HTTP ServerÌṩµÄÒ»¸ö¹¤¾ß¡£ÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁîÌìÉúÑéÖ¤Îļþ£º

htpasswd -c /etc/nginx/conf.d/.htpasswd user1

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁÔÚÖ¸¶¨Â·¾¶ÏÂÌìÉúÒ»¸ö.htpasswdÎļþ £¬²¢ÎªÓû§user1ÉèÖÃÃÜÂ롣ΪÁËÔöÌí¸ü¶àÓû§ £¬¿ÉÒÔÈ¥µô-cÑ¡Ïî £¬ÈçÏÂËùʾ£º

htpasswd /etc/nginx/conf.d/.htpasswd user2

µÇ¼ºó¸´ÖÆ

ÔÚÕâÖ®ºó £¬Äú¿ÉÒÔƾ֤ÐèÒª¼ÌÐøΪ¸ü¶àÓû§ÉèÖÃÃÜÂë¡£

×îºó £¬ÎÒÃÇÐèÒªÖØÆôNginxЧÀÍÆ÷ʹÉèÖÃÉúЧ¡£ÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁ

sudo service nginx restart

µÇ¼ºó¸´ÖÆ

ÏÖÔÚ £¬Ö»ÓÐÔÚÑéÖ¤ÎļþÖб£´æµÄÓû§²Å»ª»á¼û±»ÏÞÖƵÄURL·¾¶¡£ÆäËûÓû§½«ÎÞ·¨Í¨¹ýÊÚȨ £¬´Ó¶øÔöÌíÁËÍøÕ¾µÄÇå¾²ÐÔ¡£

×ܽ᣺

±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃNginxÉèÖÃÏÞÖÆÖ¸¶¨Óû§µÄ»á¼ûȨÏÞ¡£Ê×ÏÈ £¬ÎÒÃÇÔÚNginxÉèÖÃÎļþÖнç˵ÁËÑéÖ¤ÎļþµÄ·¾¶ £¬²¢¿ªÆôÁË»ùÓÚHTTP»ù±¾ÈÏÖ¤µÄ»á¼û¿ØÖÆ¡£È»ºó £¬Í¨¹ýlocation¿éÖ¸¶¨Á˱»ÏÞÖÆ»á¼ûµÄURL·¾¶ £¬²¢ÔÙ´ÎÖ¸¶¨ÁËÑéÖ¤ÎļþµÄ·¾¶ £¬ÒÔÏÞÖÆÖ»ÓÐÌض¨Óû§¿ÉÒÔ»á¼û¡£×îºó £¬ÎÒÃÇʹÓÃhtpasswdÏÂÁîÌìÉúÁËÑéÖ¤Îļþ £¬²¢ÖØÆôÁËNginxЧÀÍÆ÷ʹÉèÖÃÉúЧ¡£

Ï£Íû±¾ÎĶÔÄúÃ÷È·Nginx»á¼û¿ØÖÆÉèÖà £¬²¢Ñ§»áÏÞÖÆÖ¸¶¨Óû§µÄ»á¼ûȨÏÞÓÐËù×ÊÖú¡£ÈôÓÐÆäËûÎÊÌâ £¬¿É²Î¿¼Nginx¹Ù·½Îĵµ»ò¾ÙÐнøÒ»²½µÄ×ÉѯºÍÑо¿¡£

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

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ