nginx之MySQL代理


修改nginx.conf,添加如下配置(注意:stream和http是同級的):

stream {
    upstream cloudsocket {
       hash $remote_addr consistent;
       server 192.168.1.101:3389 weight=5 max_fails=3 fail_timeout=30s;
    }
    server {
       listen 25674; # 數據庫服務器監聽端口
       proxy_connect_timeout 10s;
       proxy_timeout 300s; # 設置客戶端和代理服務之間的超時時間,如果5分鍾內沒操作將自動斷開。
       proxy_pass cloudsocket;
    }
}

配置stream的前提,該Nginx要按照如下命令編譯安裝才行,否則會報錯:

./configure --prefix=/usr/local/nginx-mysql --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35 --with-stream

參考鏈接:
nginx轉發mysql連接


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM