2016-01-05 2 views
5

मैं एक टीसीपी लोड बैलेंसर होने के लिए Nginx 1.9 का उपयोग करना चाहता हूं। मैंने https://www.nginx.com/resources/admin-guide/tcp-load-balancing/ में ट्यूटोरियल का पालन किया लेकिन यह काम नहीं किया।Nginx को एक टीसीपी लोड बैलेंसर होने के लिए कॉन्फ़िगर करें

हर बार जब मैं nginx शुरू करने की कोशिश, मुझे मिल गया है त्रुटियों:

nginx: [emerg] unknown directive "stream" in /opt/nginx/nginx.conf 

यहाँ मेरी nginx.conf फ़ाइल है:

events { 
    worker_connections 1024; 
} 


http { 
# blah blah blah 
} 

stream { 
    upstream backend { 
     server 127.0.0.1:9630; 
     server 127.0.0.1:9631; 
    } 
    server { 
     listen 2802; 
     proxy_connect_timeout 1s; 
     proxy_timeout 3s; 
     proxy_pass backend; 
    } 
} 

आप कृपया मुझे बताओ कि यह कॉन्फ़िगर करने के लिए सही हैं ?

उत्तर

8

सबसे अच्छा तरीका है stream निर्देश समर्थन करने के लिए स्रोत से nginx संकलन है:

./configure --prefix=/opt/nginx --sbin-path=/usr/sbin/nginx --conf-path=/opt/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-http_ssl_module --with-threads --with-stream --with-http_slice_module 
make 
sudo make install 
+0

यह बहुत अच्छा है, लेकिन संभवतः आप पहले कमांड में केवल एक '।/Config' मतलब था? –

+0

@JimW: सही! मैंने ठीक कर दिया। – anhldbk

5

ओएस एक्स पर Homebrew का उपयोग करना, इस के साथ किया जा सकता है:

brew install nginx-full --with-stream 

यह पहली स्थापित करने के लिए आप पूछ सकते हैं homebrew-nginx टैप करें, इस मामले में आपको

brew install homebrew/nginx/nginx-full --with-stream 

यह सुनिश्चित करने के लिए कि टैप पहले इंस्टॉल हो जाए।

+1

आप स्ट्रीम एसएसएल मॉड्यूल भी चाहते हैं। मैं अल्पाइन nginx डॉकर छवि में इस्तेमाल किए गए एक के लिए एक कार्यात्मक रूप से समकक्ष निर्माण करने की कोशिश कर रहा था, और वे पूर्व निर्मित आधिकारिक nginx बाइनरी के रूप में एक ही निर्माण पैरामीटर का उपयोग कर रहे हैं: – DanielSmedegaardBuus

+0

'--with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio -with-http_v2_module --with -ipv6' – DanielSmedegaardBuus

+0

ब्रू और एसएसएल स्ट्रीम के साथ स्थापित करें, लेकिन बिना किसी किस्मत के: 'ब्रूव होमब्री/nginx/nginx-full -with-stream --with-stream_ssl_module' स्थापित करें। ऐसा लगता है कि बाद वाले को किसी भी अज्ञात पैरामीटर के साथ)। मैं इसे 'nginx -V' के साथ सत्यापित कर सकता हूं। असल में, सूची @DanielSmedegaardBuus पोस्ट की गई, केवल '--with-mail' और' --with-stream' काम करने लगती है। मैंने इसे अपने लिनक्स वीएम पर स्थापित करके हल किया, लेकिन शायद यहां कोई व्यक्ति ब्रू का उपयोग कर समाधान जानता है? –

संबंधित मुद्दे