nginx tcp 代理的實現

但在1.90發佈後增加了tcp代理模塊 所以無需安裝 參考:https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/

實現方式:

stream {
    server {
        listen 6379;
        # ...
        proxy_pass 10.59.87.121:6379;
    }
}

如果報錯:
報錯1:tcp模塊報錯
] # /data1/env/nginx/sbin/nginx -t
nginx: [emerg] "stream" directive is not allowed here in /data1/env/nginx/conf/conf.d/tcp.conf:1

原因: strem模塊不能放在http的模塊內部 ,因爲不是http協議.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章