nacos nginx grpc部署


服務端部署

部署IP:10.211.55.11 (舉例)

nacos啟動

sh startup.sh -m standalone

如集群模式參考官方文檔:
https://nacos.io/zh-cn/docs/cluster-mode-quick-start.html

啟動后會開啟:

  1. http端口8848
  2. rpc端口9848 http端口+1000
  3. 服務端節點通過端口9849 http端口+1001

Nginxs部署及配置

  1. nginx部署

    略...

  2. nginx配置

    需同時配置http的端口和grpc端口

    且grpc保持1000的offset, 這個offset客戶端是可以配置的

    主要原因是因為grpc的端口是直接在http的基本上加offset值生成,且客戶端會同時建立http和rpc的客戶端,所以兩個都需要

stream {
  upstream nacos-grpc-9848 {
    server 10.211.55.11:9848;
  }
  upstream nacos-grpc-9849 {
    server 10.211.55.11:9849;
  }

  server {
    listen 9838 ; # grpc方式對外暴露端口
    proxy_connect_timeout 1s;
    proxy_timeout 3s;
    proxy_pass nacos-grpc-9848; # 此處TCP端口轉發代理
  }

  server {
    listen 9839 ; # grpc方式對外暴露端口
    proxy_connect_timeout 1s;
    proxy_timeout 3s;
    proxy_pass nacos-grpc-9849; # 此處TCP端口轉發代理
  }
}

如是集群模式部署多個節點,一並配置到對應的upstream中

http模塊內加入如下配置:

http {
#......
#......http模塊內其它配置代碼

  upstream nacosClu {
      server 10.211.55.11:8848;
  }
  server {
          listen       8838;
          server_name  nginxIp;

          location / {
            proxy_pass http://nacosClu;
          }
          #  ignore something here
  }
  
#......
#......http模塊內其它配置代碼
}


免責聲明!

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



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