尊龙凯时人生就是搏

Nginx¶àЧÀÍÆ÷¼¯ÈºÉèÖã¬ÔöÌíÍøÕ¾¿ÉÓÃÐÔ

nginx¶àЧÀÍÆ÷¼¯ÈºÉèÖã¬ÔöÌíÍøÕ¾¿ÉÓÃÐÔ

ÔÚÏÖ´ú»¥ÁªÍøÓ¦ÓÃÖУ¬°ü¹ÜÍøÕ¾µÄ¸ß¿ÉÓÃÐÔÊÇÖÁ¹ØÖ÷ÒªµÄ¡£Ò»¸ö³£ÓõÄÒªÁìÊÇͨ¹ýÉèÖöą̀ЧÀÍÆ÷µÄ¼¯ÈºÀ´·Öµ£¸ºÔØ£¬ÒÔÌá¸ßÍøÕ¾µÄ¿ÉÓÃÐÔºÍÐÔÄÜ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNginxÀ´ÉèÖöą̀ЧÀÍÆ÷µÄ¼¯Èº£¬ÊµÏÖ¸ºÔØƽºâºÍ¹ÊÕÏתÒÆ¡£

×°ÖúÍÉèÖÃNginx

Ê×ÏÈ£¬ÐèÒªÔÚËùÓÐЧÀÍÆ÷ÉÏ×°ÖÃNginx¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´×°Öãº

sudo apt-get update
sudo apt-get install nginx

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó£¬ÐèÒª¶ÔNginx¾ÙÐлù±¾ÉèÖ᣷­¿ªNginxµÄÖ÷ÉèÖÃÎļþnginx.conf£¬Ò»Ñùƽ³£Î»ÓÚ/etc/nginx/nginx.conf£¬Ê¹ÓÃÎı¾±à¼­Æ÷¾ÙÐб༭¡£Ö÷ÒªµÄÉèÖÃÏîÈçÏ£º

http {
  upstream backend {
    server server1.example.com;
    server server2.example.com;
    server server3.example.com;
  }
  
  server {
    listen 80;
    server_name example.com;
    
    location / {
      proxy_pass http://backend;
    }
  }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöÉèÖÃÖУ¬upstream backend½ç˵Á˺ó¶ËЧÀÍÆ÷µÄÁбí¡£Äã¿ÉÒÔƾ֤ÏÖÕæÏàÐν«server1.example.comºÍserver2.example.comµÈÌ滻ΪÕæʵµÄЧÀÍÆ÷ÓòÃû»òIPµØµã¡£ÔÚserver¿éÖУ¬½«ÇëÇóͨ¹ýproxy_passÖ¸Áîת·¢µ½backendºó¶ËЧÀÍÆ÷¼¯Èº¡£

ÉèÖøºÔØƽºâ

ΪÁËʵÏÖ¸ºÔØƽºâ£¬NginxÌṩÁ˶àÖÖ¸ºÔØƽºâËã·¨¡£³£¼ûµÄÓÐÂÖѯ£¨Ä¬ÈÏ£©¡¢¼ÓȨÂÖѯ¡¢IP¹þÏ£µÈ¡£ÎÒÃÇ¿ÉÒÔÔÚupstream backend¿éÖÐͨ¹ýÌí¼Ó²î±ðµÄweightÊôÐÔÀ´ÊµÏÖ²î±ðµÄ¸ºÔØƽºâÕ½ÂÔ¡£ÒÔÏÂÊǼ¸ÖÖ³£¼ûµÄ¸ºÔØƽºâÕ½ÂÔʾÀý£º

ÂÖѯ£¨Ä¬ÈÏ£©£º

upstream backend {
  server server1.example.com;
  server server2.example.com;
  server server3.example.com;
}

µÇ¼ºó¸´ÖÆ

¼ÓȨÂÖѯ£º

upstream backend {
  server server1.example.com weight=3;
  server server2.example.com weight=2;
  server server3.example.com;
}

µÇ¼ºó¸´ÖÆ

IP¹þÏ££º

upstream backend {
  ip_hash;
  server server1.example.com;
  server server2.example.com;
  server server3.example.com;
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏʾÀý»®·Ö½ç˵ÁËÂÖѯ¡¢¼ÓȨÂÖѯºÍIP¹þÏ£ÈýÖÖ¸ºÔØƽºâÕ½ÂÔ¡£Äã¿ÉÒÔƾ֤ÏÖʵÐèÇóÑ¡ÔñÊʺϵÄÕ½ÂÔ¡£

ʵÏÖ¹ÊÕÏתÒÆ

µ±Ä³¸öºó¶ËЧÀÍÆ÷å´»ú»òÎÞ·¨Õý³£·Öµ£¸ºÔØʱ£¬ÎÒÃÇÏ£ÍûNginxÄÜ×Ô¶¯½«Á÷Á¿×ª·¢µ½ÆäËû¿ÉÓõÄЧÀÍÆ÷ÉÏ£¬ÒÔʵÏÖ¹ÊÕÏתÒÆ¡£ÎªÁËʵÏÖÕâÒ»µã£¬ÎÒÃÇ¿ÉÒÔΪÿ¸öserver¿éÌí¼ÓbackupÊôÐÔ£¬²¢ÉèÖñ¸·ÝЧÀÍÆ÷¡£

ÒÔÏÂÊÇÒ»¸öʾÀýÉèÖã¬ÆäÖÐserver2.example.comΪ±¸·ÝЧÀÍÆ÷£º

upstream backend {
  server server1.example.com;
  server server2.example.com backup;
  server server3.example.com;
}

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀýÖУ¬ÈôÊÇserver1.example.comÎÞ·¨Õý³£ÊÂÇ飬Nginx»á×Ô¶¯½«Á÷Á¿×ª·¢µ½server2.example.com¡£

ÖØмÓÔØÉèÖÃ

µ±ÄãÐÞ¸ÄÍêNginxµÄÉèÖÃÎļþºó£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÖØмÓÔØÉèÖã¬Ê¹ÐµÄÉèÖÃÉúЧ£º

sudo nginx -s reload

µÇ¼ºó¸´ÖÆ

ÕâÑù¾ÍÍê³ÉÁËNginx¶àЧÀÍÆ÷¼¯ÈºÉèÖõÄÀú³Ì¡£Í¨¹ýÉèÖöą̀ЧÀÍÆ÷µÄ¼¯Èº£¬ÊµÏÖ¸ºÔØƽºâºÍ¹ÊÕÏתÒÆ£¬¿ÉÒÔÌá¸ßÍøÕ¾µÄ¿ÉÓÃÐÔºÍÐÔÄÜ¡£

×ܽ᣺

NginxÊÇÒ»¸öÇ¿Ê¢µÄ¿ªÔ´·´ÏòÊðÀíЧÀÍÆ÷£¬Í¨¹ý¶àЧÀÍÆ÷¼¯ÈºµÄÉèÖ㬿ÉÒÔÌá¸ßÍøÕ¾µÄ¿ÉÓÃÐÔºÍÐÔÄÜ¡£±¾ÎÄÏÈÈÝÁËͨ¹ýNginxÉèÖøºÔØƽºâºÍ¹ÊÕÏתÒƵĻù±¾ÒªÁ죬²¢¸ø³öÁË´úÂëʾÀý¡£Ï£Íû¶ÁÕßÄܹ»ÔÚÏÖʵӦÓÃÖÐÎÞаÔËÓÃÕâЩÉèÖã¬Ìá¸ß×Ô¼ºÍøÕ¾µÄ¿ÉÓÃÐÔ¡£

ÒÔÉϾÍÊÇNginx¶àЧÀÍÆ÷¼¯ÈºÉèÖã¬ÔöÌíÍøÕ¾¿ÉÓÃÐÔµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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