浜斿垎閽熺湅鎳?Nginx 璐熻浇鍧囪

Posted 鏀块噰浜戝墠绔洟闃?/a>

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了浜斿垎閽熺湅鎳?Nginx 璐熻浇鍧囪相关的知识,希望对你有一定的参考价值。

馃憜   杩欐槸绗?nbsp; 43  绡?/span> 涓嶆幒姘寸殑鍘熷垱 锛屾兂瑕佷簡瑙f洿澶?/span> 锛岃鎴充笂鏂硅摑鑹插瓧浣擄細 鏀块噰浜戝墠绔洟闃?/span>  鍏虫敞鎴戜滑鍚э綖

鏈枃棣栧彂浜庢斂閲囦簯鍓嶇鍥㈤槦鍗氬锛氫簲鍒嗛挓鐪嬫噦 nginx 璐熻浇鍧囪 

https://www.zoo.team/article/nginx



鍓嶈█

瀵逛簬鐢靛晢骞冲彴鑰岃█锛岄殢鐫€涓氬姟鐨勪笉鏂彂灞曞.澶э紝缃戠珯璁块棶閲忓拰鏁版嵁閲忎篃闅忎箣鎬ュ墽澧為暱锛岃鎯呭喌鐨勪骇鐢熺粰鏈嶅姟鍣ㄥ甫鏉ヤ簡涓€瀹氱殑璐熸媴銆備粠鐢ㄦ埛浣撻獙灞傞潰鑰岃█锛岀敱浜庢湇鍔″櫒绔暟鎹鐞嗗甫鏉ョ殑鏃跺欢锛屽線寰€瀵艰嚧椤甸潰鐨勫搷搴旈€熷害杩囨參銆佹搷浣滄祦鐣呮€у彈闃荤瓑闂銆傝繖鍦ㄦ煇绉嶇▼搴︿笂鐢氳嚦浼氭綔鍦ㄥ奖鍝嶅钩鍙扮殑鎴愪氦閲忋€傛彁渚涢珮鏁堢巼锛岄珮璐ㄩ噺鐨勬湇鍔℃垚涓轰簾寰呰В鍐崇殑闂銆傝礋杞藉潎琛$瓥鐣ョ殑鍑虹幇鍜屽彂灞曟垚涓虹紦瑙d笂杩伴棶棰樼殑鏈夋晥閫斿緞銆傛湰鏂囧皢甯︿綘浜嗚В鍩轰簬 Nginx 瀹炵幇鐨勮礋杞藉潎琛°€?/p>

浠€涔堟槸璐熻浇鍧囪 

璐熻浇鍧囪 锛圠oad Balance锛夛紝瀹冨湪缃戠粶鐜版湁缁撴瀯涔嬩笂鍙互鎻愪緵涓€绉嶅粔浠枫€佹湁鏁堛€侀€忔槑鐨勬柟娉曟潵鎵╁睍缃戠粶璁惧鍜屾湇鍔″櫒鐨勫甫瀹斤紝骞跺彲浠ュ湪涓€瀹氱▼搴︿笂澧炲姞鍚炲悙閲忋€佸姞寮虹綉缁滄暟鎹鐞嗚兘鍔涖€佹彁楂樼綉缁滅殑鐏垫椿鎬у拰鍙敤鎬х瓑銆傜敤瀹樼綉鐨勮瘽璇达紝瀹冨厖褰撶潃缃戠粶娴佷腑鈥滀氦閫氭寚鎸ュ畼鈥濈殑瑙掕壊锛屸€滅珯鍦ㄢ€濇湇鍔″櫒鍓嶅鐞嗘墍鏈夋湇鍔″櫒绔拰瀹㈡埛绔箣闂寸殑璇锋眰锛屼粠鑰屾渶澶х▼搴﹀湴鎻愰珮鍝嶅簲閫熺巼鍜屽閲忓埄鐢ㄧ巼锛屽悓鏃剁‘淇濅换浣曟湇鍔″櫒閮芥病鏈夎秴璐熻嵎宸ヤ綔銆傚鏋滃崟涓湇鍔″櫒鍑虹幇鏁呴殰锛岃礋杞藉潎琛$殑鏂规硶浼氬皢娴侀噺閲嶅畾鍚戝埌鍏朵綑鐨勯泦缇ゆ湇鍔″櫒锛屼互淇濊瘉鏈嶅姟鐨勭ǔ瀹氭€с€傚綋鏂扮殑鏈嶅姟鍣ㄦ坊鍔犲埌鏈嶅姟鍣ㄧ粍鍚庯紝涔熷彲閫氳繃璐熻浇鍧囪 鐨勬柟娉曚娇鍏跺紑濮嬭嚜鍔ㄥ鐞嗗鎴风鍙戞潵鐨勮姹傘€傝鎯呭彲鍙傝€冿細What Is Load Balancing? (https://www.Nginx.com/resources/glossary/load-balancing/)

绠€瑷€涔嬶紝璐熻浇鍧囪 瀹為檯涓婂氨鏄皢澶ч噺璇锋眰杩涜鍒嗗竷寮忓鐞嗙殑绛栫暐銆?/p>

浠€涔堟槸 Nginx 璐熻浇鍧囪 

閫氳繃涓婃枃绠€鍗曠殑姒傚康浠嬬粛锛屼綘鍙兘瀵硅礋杞藉潎琛℃湁浜嗕竴涓垵姝ョ殑浜嗚В锛岀煡閬撳畠鏄竴绉嶈皟搴︾瓥鐣ャ€傞偅涔堥棶棰樻潵浜嗭紝Nginx 鍙堟槸浠€涔堝憿锛烴ginx 濡備綍瀹炵幇璐熻浇鍧囪 锛熻繖灏辫浠庢鍚戜唬鐞嗗拰鍙嶅悜浠g悊璇磋捣浜嗐€?/p>

  • 姝e悜浠g悊

    姝e悜浠g悊锛團orward Proxy锛夋渶澶х殑鐗圭偣鏄紝瀹㈡埛绔潪甯告槑纭璁块棶鐨勬湇鍔″櫒鍦板潃锛屽畠浠g悊瀹㈡埛绔紝鏇垮鎴风鍙戝嚭璇锋眰銆傛瘮濡傦細绉戝涓婄綉锛屼織绉扮炕澧欙紙璀﹀憡鈿狅笍锛氱炕澧欐搷浣滆繚鍙嶇浉鍏虫硶寰嬭瀹氾紝鏈枃鍙槸涓轰簡瑙i噴姝e悜浠g悊鍚戣鑰呬妇涓緥瀛愶紝浠呬緵瀛︿範鍙傝€冿紝鍒囧嬁鐩茬洰缈诲锛夈€?

    浜斿垎閽熺湅鎳?Nginx 璐熻浇鍧囪 

  • 鍙嶅悜浠g悊

    閭d箞锛岄殢鐫€璇锋眰閲忕殑鐖嗗彂寮忓闀匡紝鏈嶅姟鍣ㄨ寰楄嚜宸变竴涓汉濮嬬粓鏄簲浠樹笉杩囨潵锛岄渶瑕佸厔寮熸湇鍔″櫒浠府蹇欙紝浜庢槸瀹冨枈鏉ヤ簡鑷繁鐨勫厔寮熶互鍙婁唬鐞嗘湇鍔″櫒鏈嬪弸銆傛鏃讹紝鏉ヨ嚜涓嶅悓瀹㈡埛绔殑鎵€鏈夎姹傚疄闄呬笂閮藉彂鍒颁簡浠g悊鏈嶅姟鍣ㄥ锛屽啀鐢变唬鐞嗘湇鍔″櫒鎸夌収涓€瀹氱殑瑙勫垯灏嗚姹傚垎鍙戠粰鍚勪釜鏈嶅姟鍣ㄣ€?/p>

    杩欏氨鏄弽鍚戜唬鐞嗭紙Reverse Proxy锛夛紝鍙嶅悜浠g悊闅愯棌浜嗘湇鍔″櫒鐨勪俊鎭紝瀹冧唬鐞嗙殑鏄湇鍔″櫒绔紝浠e叾鎺ユ敹璇锋眰銆傛崲鍙ヨ瘽璇达紝鍙嶅悜浠g悊鐨勮繃绋嬩腑锛屽鎴风骞朵笉鐭ラ亾鍏蜂綋鏄摢鍙版湇鍔″櫒澶勭悊浜嗚嚜宸辩殑璇锋眰銆傚姝や竴鏉ワ紝鏃㈡彁楂樹簡璁块棶閫熷害锛屽張涓哄畨鍏ㄦ€ф彁渚涗簡淇濊瘉銆?

    浜斿垎閽熺湅鎳?Nginx 璐熻浇鍧囪 


    鍦ㄨ繖涔嬩腑锛屽弽鍚戜唬鐞嗛渶瑕佽€冭檻鐨勯棶棰樻槸锛屽浣曡繘琛屽潎琛″垎宸ワ紝鎺у埗娴侀噺锛岄伩鍏嶅嚭鐜板眬閮ㄨ妭鐐硅礋杞借繃澶х殑闂銆?/span>閫氫織鐨勮锛屽氨鏄浣曚负姣忓彴鏈嶅姟鍣ㄥ悎鐞嗙殑鍒嗛厤璇锋眰锛屼娇鍏舵暣浣撳叿鏈夋洿楂樼殑宸ヤ綔鏁堢巼鍜岃祫婧愬埄鐢ㄧ巼銆?/span>

  • Nginx 鏄粈涔堬紵

    Nginx 浣滀负涓€涓熀浜?C 瀹炵幇鐨勯珮鎬ц兘 Web 鏈嶅姟鍣紝鍙互閫氳繃绯诲垪绠楁硶瑙e喅涓婅堪鐨勮礋杞藉潎琛¢棶棰樸€傚苟涓旂敱浜庡畠鍏锋湁楂樺苟鍙戙€侀珮鍙潬鎬с€侀珮鎵╁睍鎬с€佸紑婧愮瓑鐗圭偣锛屾垚涓哄紑鍙戜汉鍛樺父鐢ㄧ殑鍙嶅悜浠g悊宸ュ叿銆?/p>

璐熻浇鍧囪 甯哥敤绠楁硶

1. 杞 锛坮ound-robin锛?/strong>

杞涓鸿礋杞藉潎琛′腑杈冧负鍩虹涔熻緝涓虹畝鍗曠殑绠楁硶锛屽畠涓嶉渶瑕侀厤缃澶栧弬鏁般€傚亣璁鹃厤缃枃浠朵腑鍏辨湁 鍙版湇鍔″櫒锛岃绠楁硶閬嶅巻鏈嶅姟鍣ㄨ妭鐐瑰垪琛紝骞舵寜鑺傜偣娆″簭姣忚疆閫夋嫨涓€鍙版湇鍔″櫒澶勭悊璇锋眰銆傚綋鎵€鏈夎妭鐐瑰潎琚皟鐢ㄨ繃涓€娆″悗锛岃绠楁硶灏嗕粠绗竴涓妭鐐瑰紑濮嬮噸鏂颁竴杞亶鍘嗐€?/p>

鐗圭偣锛氱敱浜庤绠楁硶涓瘡涓姹傛寜鏃堕棿椤哄簭閫愪竴鍒嗛厤鍒颁笉鍚岀殑鏈嶅姟鍣ㄥ鐞嗭紝鍥犳閫傜敤浜庢湇鍔″櫒鎬ц兘鐩歌繎鐨勯泦缇ゆ儏鍐碉紝鍏朵腑姣忎釜鏈嶅姟鍣ㄦ壙杞界浉鍚岀殑璐熻浇銆備絾瀵逛簬鏈嶅姟鍣ㄦ€ц兘涓嶅悓鐨勯泦缇よ€岃█锛岃绠楁硶瀹规槗寮曞彂璧勬簮鍒嗛厤涓嶅悎鐞嗙瓑闂銆?/p>

2銆佸姞鏉冭疆璇?/strong>

涓轰簡閬垮厤鏅€氳疆璇㈠甫鏉ョ殑寮婄锛屽姞鏉冭疆璇㈠簲杩愯€岀敓銆傚湪鍔犳潈杞涓紝姣忎釜鏈嶅姟鍣ㄤ細鏈夊悇鑷殑 weight銆備竴鑸儏鍐典笅锛?code class="mq-72">weight 鐨勫€艰秺澶ф剰鍛崇潃璇ユ湇鍔″櫒鐨勬€ц兘瓒婂ソ锛屽彲浠ユ壙杞芥洿澶氱殑璇锋眰銆傝绠楁硶涓紝瀹㈡埛绔殑璇锋眰鎸夋潈鍊兼瘮渚嬪垎閰嶏紝褰撲竴涓姹傚埌杈炬椂锛屼紭鍏堜负鍏跺垎閰嶆潈鍊兼渶澶х殑鏈嶅姟鍣ㄣ€?/p>

鐗圭偣锛氬姞鏉冭疆璇㈠彲浠ュ簲鐢ㄤ簬鏈嶅姟鍣ㄦ€ц兘涓嶇瓑鐨勯泦缇や腑锛屼娇璧勬簮鍒嗛厤鏇村姞鍚堢悊鍖栥€?/p>

Nginx 鍔犳潈杞婧愮爜鍙锛? ngx_http_upstream_round_robin.c (https://github.com/nginx/nginx/blob/master/src/http/ngx_http_upstream_round_robin.c)锛屾簮鐮佸垎鏋愬彲鍙傝€冿細 鍏充簬杞绛栫暐鍘熺悊鐨勮嚜鎴戠悊瑙?/strong> (https://blog.csdn.net/BlacksunAcheron/article/details/84439302)銆傚叾鏍稿績鎬濇兂鏄紝閬嶅巻鍚勬湇鍔″櫒鑺傜偣锛屽苟璁$畻鑺傜偣鏉冨€硷紝璁$畻瑙勫垯涓? current_weight 涓庡叾瀵瑰簲鐨? effective_weight 涔嬪拰锛屾瘡杞亶鍘嗕腑閫夊嚭鏉冨€兼渶澶х殑鑺傜偣浣滀负鏈€浼樻湇鍔″櫒鑺傜偣銆傚叾涓? effective_weight 浼氬湪绠楁硶鐨勬墽琛岃繃绋嬩腑闅忚祫婧愭儏鍐靛拰鍝嶅簲鎯呭喌鑰屾敼鍙樸€傝緝涓烘牳蹇冪殑閮ㄥ垎濡備笅锛?
for (peer = rrp->peers->peer, i = 0;
peer; /* peer 涓哄綋鍓嶉亶鍘嗙殑鏈嶅姟鍣ㄧ粨鐐?/
peer = peer->next, i++)
{
...

/* 姣忚疆閬嶅巻浼氭洿鏂?peer 褰撳墠鐨勬潈鍊?/
peer->current_weight += peer->effective_weight;

...

/* best 涓哄綋鍓嶆湇鍔″櫒涓殑鏈€浼樿妭鐐癸紝鍗虫湰杞腑閫変腑鐨勬湇鍔″櫒鑺傜偣*/
if (best == NULL || peer->current_weight > best->current_weight) {
best = peer;
p = i;
}

...
}
3. IP 鍝堝笇锛圛P hash锛?/strong>

ip_hash 渚濇嵁鍙戝嚭璇锋眰鐨勫鎴风 IP 鐨?hash 鍊兼潵鍒嗛厤鏈嶅姟鍣紝璇ョ畻娉曞彲浠ヤ繚璇佸悓 IP 鍙戝嚭鐨勮姹傛槧灏勫埌鍚屼竴鏈嶅姟鍣紝鎴栬€呭叿鏈夌浉鍚?hash 鍊肩殑涓嶅悓 IP 鏄犲皠鍒板悓涓€鏈嶅姟鍣ㄣ€?/p>

鐗圭偣锛氳绠楁硶鍦ㄤ竴瀹氱▼搴︿笂瑙e喅浜嗛泦缇ら儴缃茬幆澧冧笅 Session 涓嶅叡浜殑闂銆?/p>

鈥?/span>

Session 涓嶅叡浜棶棰樻槸璇达紝鍋囪鐢ㄦ埛宸茬粡鐧诲綍杩囷紝姝ゆ椂鍙戝嚭鐨勮姹傝鍒嗛厤鍒颁簡 A 鏈嶅姟鍣紝浣?A 鏈嶅姟鍣ㄧ獊鐒跺畷鏈猴紝鐢ㄦ埛鐨勮姹傚垯浼氳杞彂鍒?B 鏈嶅姟鍣ㄣ€備絾鐢变簬 Session 涓嶅叡浜紝B 鏃犳硶鐩存帴璇诲彇鐢ㄦ埛鐨勭櫥褰曚俊鎭潵缁х画鎵ц鍏朵粬鎿嶄綔銆?/p>

瀹為檯搴旂敤涓紝鎴戜滑鍙互鍒╃敤 ip_hash锛屽皢涓€閮ㄥ垎 IP 涓嬬殑璇锋眰杞彂鍒拌繍琛屾柊鐗堟湰鏈嶅姟鐨勬湇鍔″櫒锛屽彟涓€閮ㄥ垎杞彂鍒版棫鐗堟湰鏈嶅姟鍣ㄤ笂锛屽疄鐜扮伆搴﹀彂甯冦€傚啀鑰咃紝濡傞亣鍒版枃浠惰繃澶у鑷磋姹傝秴鏃剁殑鎯呭喌锛屼篃鍙互鍒╃敤 ip_hash 杩涜鏂囦欢鐨勫垎鐗囦笂浼狅紝瀹冨彲浠ヤ繚璇佸悓瀹㈡埛绔彂鍑虹殑鏂囦欢鍒囩墖杞彂鍒板悓涓€鏈嶅姟鍣紝鍒╀簬鍏舵帴鏀跺垏鐗囦互鍙婂悗缁殑鏂囦欢鍚堝苟鎿嶄綔銆?/p>

4銆佸叾浠栫畻娉?/strong>

  • URL hash

    url_hash 鏄牴鎹姹傜殑 URL 鐨?hash 鍊兼潵鍒嗛厤鏈嶅姟鍣ㄣ€傝绠楁硶鐨勭壒鐐规槸锛岀浉鍚?URL 鐨勮姹備細鍒嗛厤缁欏浐瀹氱殑鏈嶅姟鍣紝褰撳瓨鍦ㄧ紦瀛樼殑鏃跺€欙紝鏁堢巼涓€鑸緝楂樸€傜劧鑰?Nginx 榛樿涓嶆敮鎸佽繖绉嶈礋杞藉潎琛$畻娉曪紝闇€瑕佷緷璧栫涓夋柟搴撱€?/p>

  • 鏈€灏忚繛鎺ユ暟锛圠east Connections锛?/p>

    鍋囪鍏辨湁 鍙版湇鍔″櫒锛屽綋鏈夋柊鐨勮姹傚嚭鐜版椂锛岄亶鍘嗘湇鍔″櫒鑺傜偣鍒楄〃骞堕€夊彇鍏朵腑杩炴帴鏁版渶灏忕殑涓€鍙版湇鍔″櫒鏉ュ搷搴斿綋鍓嶈姹傘€傝繛鎺ユ暟鍙互鐞嗚В涓哄綋鍓嶅鐞嗙殑璇锋眰鏁般€?/p>

搴旂敤鍦烘櫙

璇翠簡杩欎箞澶氱悊璁猴紝绌剁珶鍩轰簬 Nginx 鐨勮礋杞藉潎琛¤鎬庝箞鐢ㄥ憿锛熸帴涓嬫潵锛屽皢浠ュ姞鏉冭疆璇㈢畻娉曚负渚嬶紝甯﹀ぇ瀹跺皾璇曢€氳繃鑷繁鐨勪竴鍙扮瑪璁版湰 + Nginx + Node 娴嬭瘯涓€涓嬭礋杞藉潎琛°€傜敱浜庢病鏈夊鍙版湇鍔″櫒锛屼簬鏄€氳繃鑷繁绗旇鏈殑澶氫釜涓嶅悓绔彛鏉ユā鎷熶笉鍚岀殑鏈嶅姟鍣ㄣ€?/p>

Step 1锛氱‘淇濊嚜宸辩殑鐢佃剳涓紝Nginx 宸插畨瑁呭苟鑳藉鎴愬姛鍚姩锛堜互 Mac 涓轰緥锛?/p>

濡傛灉浣犱篃閬囧埌浜嗗儚鎴戜竴鏍风敱浜庣鍙e崰鐢ㄥ鑷?Nginx 鍚姩澶辫触鐨勯棶棰橈紝鍙互灏濊瘯涓嬭堪姝ラ淇敼閰嶇疆鏂囦欢涓殑绔彛鍙?/p>

  • 鐩稿叧鏂囦欢璺緞

    • /usr/local/etc/nginx/nginx.conf 锛堥厤缃枃浠惰矾寰勶級
    • /usr/local/var/www 锛堟湇鍔″櫒榛樿璺緞锛?
    • /usr/local/Cellar/nginx/1.8.0 锛堝畨瑁呰矾寰勶級
  • 淇敼 nginx.conf 鏂囦欢涓殑绔彛
server {
# listen 8080;
listen 8086;
server_name localhost;
}
Nginx 閰嶇疆鏂囦欢 nginx.conf 涓富瑕佸寘鍚互涓嬪嚑涓儴鍒嗭細
  • server锛氫富鏈烘湇鍔$浉鍏宠缃紝涓昏鐢ㄤ簬鎸囧畾铏氭嫙涓绘満鍩熷悕銆両P 鍜岀鍙?/p>

  • location锛歎RL 鍖归厤鐗瑰畾浣嶇疆鍚庣殑璁剧疆锛屽弽鍚戜唬鐞嗚缃?/p>

  • upstream锛氳礋杞藉潎琛$浉鍏抽厤缃?/p>

  • 鏆傚仠 Nginx 骞堕噸鍚?/p>

// 鏆傚仠 Nginx 鏈嶅姟
sudo nginx -s stop
// 鍚姩 Nginx 鏈嶅姟
nginx
  • 鎵撳紑 http://localhost:8086/ 娴嬭瘯鏄惁鎴愬姛锛屽鏋滄樉绀轰笅鍥撅紝鍒欒瘉鏄庡惎鍔ㄦ垚鍔燂綖

    浜斿垎閽熺湅鎳?Nginx 璐熻浇鍧囪 
    nginx

Step 2锛氬熀浜?Node + Express 妗嗘灦鏉ユ惌寤虹畝鍗曠殑鏈嶅姟鍣?/p>

Express 鏄竴涓畝娲佽€岀伒娲荤殑杞婚噺绾?node.js Web 搴旂敤妗嗘灦锛岃鎯呭彲浜嗚В Express (http://www.expressjs.com.cn/)锛屽鏋滅涓€娆′娇鐢紝璇峰厛瀹夎銆?/p>

  • 瀹夎 Express

npm i express
  • 鏂板缓 index.js 鏂囦欢锛屽苟鍐欏叆浠g爜
const express = require('express');
const app = express();

// 瀹氫箟瑕佺洃鍚殑绔彛鍙?/span>
const listenedPort = '8087';

app.get('/', (req, res) => res.send(`Hello World! I am port ${listenedPort}锝瀈));

// 鐩戝惉绔彛
app.listen(listenedPort, () => console.log(`success: ${listenedPort}`));
  • 鍚姩鏈嶅姟鍣?
node index.js
姝ゅ鍙互澶氳捣鍑犱釜鏈嶅姟锛屽垎鍒 Node 鐩戝惉 8087锛?088锛?089 绔彛锛屾瘡涓湇鍔′腑閫氳繃 send 涓嶅悓鐨勬枃妗堢敤浠ュ尯鍒嗕笉鍚岀殑 Server銆?

Step 3锛氬湪 nginx.conf 鏂囦欢涓厤缃ソ闇€瑕佽疆璇㈢殑鏈嶅姟鍣ㄥ拰浠g悊

  • 杞鐨勬湇鍔″櫒锛屽啓鍦?http 涓殑 upstream 瀵硅薄閲岋細

upstream testServer {
server localhost:8087 weight=10;
server localhost:8088 weight=2;
server localhost:8089;
}
  • 浠g悊鍦板潃锛屽啓鍦?http 涓殑 server 瀵硅薄閲岋細
location / {
root html;
index index.html index.htm;
proxy_pass http://testServer; // testServer 涓鸿嚜宸卞畾涔夌殑鏈嶅姟鍣ㄩ泦缇?br>}
Step 4锛氭煡鐪嬬粨鏋?
  • 閲嶅惎 Nginx 鏈嶅姟

  • 鍐嶆鎵撳紑 http://localhost:8086/
    load-balance

    閫氳繃澶氭鍒锋柊鍙互鍙戠幇锛岀敱浜庤缃簡涓嶅悓鐨?weight锛岀鍙e彿涓?8087 鐨勬湇鍔″櫒鍑虹幇鐨勬鏁版渶澶氾紝鍚屾椂璇佸疄浜嗘潈鍊艰秺楂橈紝鏈嶅姟鍣ㄥ鐞嗚姹傚嚑鐜囪秺澶х殑瑙勫垯銆?/p>

鎬荤粨

Nginx 浣滀负涓€娆句紭绉€鐨勫弽鍚戜唬鐞嗘湇鍔″櫒锛屽彲浠ラ€氳繃涓嶅悓鐨勮礋杞藉潎琛$畻娉曟潵瑙e喅璇锋眰閲忚繃澶ф儏鍐典笅鐨勬湇鍔″櫒璧勬簮鍒嗛厤闂銆傝緝涓哄父瑙佺殑璐熻浇鍧囪 绠楁硶鏈夎疆璇€佸姞鏉冭疆璇€両P 鍝堝笇绛夌瓑锛屽彲鍒嗗埆搴斿涓嶅悓鐨勮姹傚満鏅€傚鏋滄湁鍏磋叮鍙互鍘?Github 鐞嗚В涓嬪ぇ绁炵殑婧愮爜锛屾湁闂涔熸杩庝竴璧锋潵鎺㈣锝?/p>

鍙傝€冩枃鐚?/span>

  • 鍏充簬杞绛栫暐鍘熺悊鐨勮嚜鎴戠悊瑙?/strong> (https://blog.csdn.net/BlacksunAcheron/article/details/84439302)

  • Nginx 鐩稿叧浠嬬粛(Nginx鏄粈涔?鑳藉共鍢?) (https://www.cnblogs.com/wcwnina/p/8728391.html)

鐪嬪畬涓や欢浜?/span>

濡傛灉浣犺寰楄繖绡囧唴瀹瑰浣犳尯鏈夊惎鍙戯紝鎴戞兂閭€璇蜂綘甯垜涓や欢灏忎簨

1.鐐逛釜銆?span class="mq-234">鍦ㄧ湅銆嶏紝璁╂洿澶氫汉涔熻兘鐪嬪埌杩欑瘒鍐呭锛堝枩娆笉鐐瑰湪鐪嬬殑锛岄兘鏄€嶆祦姘擄級

鎷涜搐绾冲+

鏀块噰浜戝墠绔洟闃燂紙ZooTeam锛夛紝涓€涓勾杞诲瘜鏈夋縺鎯呭拰鍒涢€犲姏鐨勫墠绔洟闃燂紝闅跺睘浜庢斂閲囦簯浜у搧鐮斿彂閮紝Base 鍦ㄩ鏅鐢荤殑鏉窞銆傚洟闃熺幇鏈?50 浣欎釜鍓嶇灏忎紮浼达紝骞冲潎骞撮緞 27 宀侊紝杩?3 鎴愭槸鍏ㄦ爤宸ョ▼甯堬紝濡ュΕ鐨勯潚骞撮鏆村洟銆傛垚鍛樻瀯鎴愭棦鏈夋潵鑷簬闃块噷銆佺綉鏄撶殑鈥滆€佲€濆叺锛屼篃鏈夋禉澶с€佷腑绉戝ぇ銆佹澀鐢电瓑鏍$殑搴斿眾鏂颁汉銆傚洟闃熷湪鏃ュ父鐨勪笟鍔″鎺ヤ箣澶栵紝杩樺湪鐗╂枡浣撶郴銆佸伐绋嬪钩鍙般€佹惌寤哄钩鍙般€佹€ц兘浣撻獙銆佷簯绔簲鐢ㄣ€佹暟鎹垎鏋愬強鍙鍖栫瓑鏂瑰悜杩涜鎶€鏈帰绱㈠拰瀹炴垬锛屾帹鍔ㄥ苟钀藉湴浜嗕竴绯诲垪鐨勫唴閮ㄦ妧鏈骇鍝侊紝鎸佺画鎺㈢储鍓嶇鎶€鏈綋绯荤殑鏂拌竟鐣屻€?/p>

濡傛灉浣犳兂鏀瑰彉涓€鐩磋浜嬫姌鑵撅紝甯屾湜寮€濮嬭兘鎶樿吘浜嬶紱濡傛灉浣犳兂鏀瑰彉涓€鐩磋鍛婅闇€瑕佸浜涙兂娉曪紝鍗存棤浠庣牬灞€锛涘鏋滀綘鎯虫敼鍙樹綘鏈夎兘鍔涘幓鍋氭垚閭d釜缁撴灉锛屽嵈涓嶉渶瑕佷綘锛涘鏋滀綘鎯虫敼鍙樹綘鎯冲仛鎴愮殑浜嬮渶瑕佷竴涓洟闃熷幓鏀拺锛屼絾娌′綘甯︿汉鐨勪綅缃紱濡傛灉浣犳兂鏀瑰彉鏃㈠畾鐨勮妭濂忥紝灏嗕細鏄€? 骞村伐浣滄椂闂?3 骞村伐浣滅粡楠屸€濓紱濡傛灉浣犳兂鏀瑰彉鏈潵鎮熸€т笉閿欙紝浣嗘€绘槸鏈夐偅涓€灞傜獥鎴风焊鐨勬ā绯娾€?濡傛灉浣犵浉淇$浉淇$殑鍔涢噺锛岀浉淇″钩鍑′汉鑳芥垚灏遍潪鍑′簨锛岀浉淇¤兘閬囧埌鏇村ソ鐨勮嚜宸便€傚鏋滀綘甯屾湜鍙備笌鍒伴殢鐫€涓氬姟鑵鹃鐨勮繃绋嬶紝浜叉墜鎺ㄥ姩涓€涓湁鐫€娣卞叆鐨勪笟鍔$悊瑙c€佸畬鍠勭殑鎶€鏈綋绯汇€佹妧鏈垱閫犱环鍊笺€佸奖鍝嶅姏澶栨孩鐨勫墠绔洟闃熺殑鎴愰暱鍘嗙▼锛屾垜瑙夊緱鎴戜滑璇ヨ亰鑱娿€備换浣曟椂闂达紝绛夌潃浣犲啓鐐逛粈涔堬紝鍙戠粰 ZooTeam@cai-inc.com

以上是关于浜斿垎閽熺湅鎳?Nginx 璐熻浇鍧囪的主要内容,如果未能解决你的问题,请参考以下文章

nginx鍩轰簬HTTP瀹炵幇璐熻浇鍧囪 tomcat

Linux璐熻浇鍧囪 鍜屼腑闂翠欢

璐熻浇鍧囪

璐熻浇鍧囪 涔?LVS

鍩轰簬Haproxy鏋勫缓璐熻浇鍧囪 闆嗙兢

2019.9.21 Tomcat缃戦〉浣嶇疆鐨勪慨鏀瑰強璐熻浇鍧囪