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

nginxÔõôÆôÓÃstream

ÔõÑùÆôÓà nginx µÄ stream Ä£¿é£¿ÆôÓà stream Ä£¿éÐèÒªÁù¸ö°ì·¨£º×°Öà stream Ä£¿éÉèÖà nginx½¨Éè stream ЧÀÍÆ÷¿éÉèÖà stream ЧÀÍÆ÷Ñ¡ÏîÖØÆô nginxÑéÖ¤ÆôÓÃ

ÔõÑùÆôÓà Nginx µÄ Stream Ä£¿é

ÆôÓà Nginx µÄ Stream Ä£¿éºÜÊǼòÆÓ£¬Ö»ÐèÖ´ÐÐÒÔÏ°취£º

1. ×°Öà Stream Ä£¿é

Ê×ÏÈ£¬ÐèҪȷ±£ÄúÒÑ×°ÖÃÁË Nginx Stream Ä£¿é¡£ÔÚ´ó´ó¶¼ Linux ¿¯ÐаæÉÏ£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº

sudo apt install nginx-stream-module

µÇ¼ºó¸´ÖÆ

»ò£º

sudo yum install nginx-stream-module

µÇ¼ºó¸´ÖÆ

2. ÉèÖÃ Nginx

×°ÖÃÄ£¿éºó£¬ÄúÐèÒªÔÚ Nginx ÉèÖÃÎļþÖмÓÔØËü¡£·­¿ª Nginx ÉèÖÃÎļþ (/etc/nginx/nginx.conf)£¬²¢ÔÚ http ¿éÖ®ÍâÌí¼ÓÒÔÏÂÐУº

load_module modules/ngx_stream_module.so;

µÇ¼ºó¸´ÖÆ

3. ½¨Éè Stream ЧÀÍÆ÷¿é

½ÓÏÂÀ´£¬ÄúÐèÒª½¨ÉèÒ»¸ö Stream ЧÀÍÆ÷¿éÀ´½ç˵½«Ê¹Óà Stream Ä£¿éµÄЧÀÍÆ÷µÄÉèÖá£ÔÚ Nginx ÉèÖÃÎļþÖУ¬Ìí¼ÓÒÔÏ£º

stream {
    server {
        listen 8080;

        # ÕâÀïÉèÖà Stream ЧÀÍÆ÷µÄÑ¡Ïî...
    }
}

µÇ¼ºó¸´ÖÆ

4. ÉèÖà Stream ЧÀÍÆ÷Ñ¡Ïî

ÔÚÕâ¸ö Stream ЧÀÍÆ÷¿éÖУ¬Äú¿ÉÒÔÉèÖÃÖÖÖÖÑ¡ÏîÀ´¿ØÖÆЧÀÍÆ÷µÄÐÐΪ¡£ÀýÈ磬Äú¿ÉÒÔÖ¸¶¨Òª¼àÌýµÄ¶Ë¿Ú£¨ÔÚ±¾ÀýÖÐΪ 8080£©£¬ÒÔ¼°ÒªÊ¹ÓõÄЭÒ飨Èç TCP¡¢UDP »ò TLS£©¡£

5. ÖØÆô Nginx

×îºó£¬ÖØÐÂÆô¶¯ Nginx ÒÔÓ¦Óøü¸Ä£º

sudo systemctl restart nginx

µÇ¼ºó¸´ÖÆ

6. ÑéÖ¤ÆôÓÃ

ÏÖÔÚ£¬Stream Ä£¿éÒÑÆôÓã¬Äú¿ÉÒÔͨ¹ý¼ì²é Nginx Àú³ÌÁбíÀ´ÑéÖ¤£º

sudo systemctl status nginx | grep -i stream

µÇ¼ºó¸´ÖÆ

ÈôÊÇÊä³öÖÐÏÔʾ “ngx_stream_module (stream)”, ÔòÅú×¢ Stream Ä£¿éÒÑÀÖ³ÉÆôÓá£

ÒÔÉϾÍÊÇnginxÔõôÆôÓÃstreamµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ