尊龙凯时人生就是搏

nginxÔõÑùÉèÖøºÔØƽºâ

ÔõÑùÉèÖà nginx ¾ÙÐиºÔØƽºâ£¿½ç˵ÉÏÓÎЧÀÍÆ÷³Ø £¬Ö¸¶¨Ð§ÀÍÆ÷ ip ºÍ¶Ë¿Ú¡£½ç˵ÐéÄâÖ÷»ú £¬¼àÌýÅþÁ¬²¢×ª·¢µ½ÉÏÓγØ¡£Ö¸¶¨Î»Öà £¬Æ¥ÅäÇëÇó²¢×ª·¢µ½ÉÏÓγØ¡£

Nginx ÉèÖøºÔØƽºâÖ¸ÄÏ

¸ºÔØƽºâÊÇÒ»ÖÖÍøÂçÊÖÒÕ £¬¿É½«´«ÈëÁ÷Á¿ÂþÑܵ½¶à¸öЧÀÍÆ÷ÉÏ £¬ÒÔÌá¸ßÐÔÄܲ¢ÔöÇ¿¿ÉÓÃÐÔ¡£Nginx ÊÇÒ»¿îÊ¢ÐÐµÄ Web ЧÀÍÆ÷ £¬¿ÉÓÃÓÚÉèÖøºÔØƽºâ¡£

ÉèÖð취

ÒªÉèÖà Nginx ¸ºÔØƽºâ £¬ÇëÔÚ Nginx ÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÖ¸Á

upstream my_upstream {
    server 192.168.1.100:80;
    server 192.168.1.101:80;
    server 192.168.1.102:80;
}

server {
    listen 80;
    server_name my-domain.com;
    location / {
        proxy_pass http://my_upstream;
    }
}

µÇ¼ºó¸´ÖÆ

Ïêϸ˵Ã÷

upstream ¿é½ç˵ÁËÉÏÓÎЧÀÍÆ÷³Ø £¬ÆäÖаüÀ¨Òª¾ÙÐиºÔØƽºâµÄЧÀÍÆ÷Áбí¡£server Ö¸ÁîÖ¸¶¨Ã¿Ì¨Ð§ÀÍÆ÷µÄ IP µØµãºÍ¶Ë¿Ú¡£

server ¿é½ç˵ÁËÒ»¸öÐéÄâÖ÷»ú £¬Ëü¼àÌý´«ÈëµÄÅþÁ¬²¢½«Æäת·¢µ½ÉÏÓÎЧÀÍÆ÷³Ø¡£server_name Ö¸ÁîÖ¸¶¨ÐéÄâÖ÷»úµÄÖ÷»úÃû¡£location / ¿é½ç˵ÁËÒ»¸öλÖà £¬ËüÆ¥ÅäËùÓд«ÈëÇëÇó²¢½«Æäת·¢µ½ÉÏÓÎЧÀÍÆ÷³Ø¡£proxy_pass Ö¸ÁîÖ¸¶¨ÉÏÓÎЧÀÍÆ÷³ØµÄÃû³Æ¡£

¸ºÔØƽºâËã·¨

Nginx Ö§³ÖÒÔϸºÔØƽºâËã·¨£º

ÂÖѯ (least_conn)£ºÒÀ´Î½«ÇëÇó·Ö·¢µ½ÉÏÓÎЧÀÍÆ÷ £¬Ð§ÀÍÆ÷ÅþÁ¬Êý×îÉÙµÄÓÅÏÈ´¦ÀíÇëÇó¡£

ȨÖØÑ­»· (weight)£ºÆ¾Ö¤ÎªÃ¿¸öЧÀÍÆ÷ÉèÖõÄȨÖØ·ÖÅÉÇëÇó £¬È¨ÖؽϸߵÄЧÀÍÆ÷´¦Àí¸ü¶àÇëÇó¡£

IP ¹þÏ£ (ip_hash)£ºÆ¾Ö¤¿Í»§¶Ë IP µØµã¾ÙÐйþÏ£ £¬×ÜÊÇδÀ´×Ôͳһ¸ö IP µØµãµÄÇëÇó·¢Ë͵½Í³Ò»Ì¨Ð§ÀÍÆ÷¡£

¿ÉÒÔͨ¹ýÔÚupstream ¿éÖÐʹÓÃleast_conn¡¢weight »òhash µÈÖ¸ÁîÀ´ÉèÖÃÕâЩËã·¨¡£

¼à¿ØºÍ¿µ½¡¼ì²é

Nginx Ìṩ¶àÖÖ¼à¿ØºÍ¿µ½¡¼ì²é»úÖÆÀ´¼àÊÓÉÏÓÎЧÀÍÆ÷µÄÔËÐÐ״̬¡£ÀýÈç £¬¿ÉÒÔʹÓÃproxy_monitor Ä£¿éÆôÓÃ×Ô¶¯¿µ½¡¼ì²é £¬ÈôÊÇЧÀÍÆ÷ÏìÓ¦²»ÊµÊ± £¬Ôò½«Æä´ÓÉÏÓÎЧÀÍÆ÷³ØÖбê¼ÇΪÍÑ»ú¡£

ÒÔÉϾÍÊÇnginxÔõÑùÉèÖøºÔØƽºâµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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