zoukankan      html  css  js  c++  java
  • 接口服务flask的负载均衡部署

    添加配置文件

    先转到http转发配置目录

    cd /etc/nginx/conf.d

    新建配置文件

    touch flask-8004.conf

    编辑并添加配置 vim flask-8004.conf

    upstream flask {
          server 192.168.6.226:8004;
          server 192.168.6.227:8004;
    }
    server {
          listen 8008;
          server_name chain_flask;
          location / {
          # 后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
          proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X_Nginx_Proxy true;
          proxy_redirect off;
          proxy_pass http://flask;
          }
    }

    其中

    upstream flask {
          server 192.168.6.226:8004;
          server 192.168.6.227:8004;
    }

    为两个用来的区块链接口服务的地址,负载均衡的方式为轮询。

    重启nginx服务

    service nginx restart

    测试

    在其他机器访问nginx监听的ip和端口测试

    curl -H "Content-Type: application/json" -X POST -d '{"token":"3Q1EbvdpmTssybyNu3pfGke1SqG2NmtBHd5qwjXYeHvV","data":“*********”}' "http://192.168.6.228:8008/blockchain/*****/******

    ----------------陌上阡头,草长莺飞----------------- https://www.cnblogs.com/tyche116/
  • 相关阅读:
    Mayan游戏
    选择客栈
    Redundant Paths
    中心选址
    辗转相除
    字符串
    线段覆盖
    配置魔药
    宝库通道
    教官的监视
  • 原文地址:https://www.cnblogs.com/tyche116/p/14467248.html
Copyright © 2011-2022 走看看