【问题标题】:Use multiple Heroku apps for load balancing Nginx使用多个 Heroku 应用程序来平衡 Nginx
【发布时间】:2019-05-27 03:49:34
【问题描述】:

我需要设计一个系统,要求:

  • 1 Node.js 服务器用于反向代理,使用 Nginx 进行负载均衡。

  • 4 Node.js 服务器用于 RESTful API。所有这些都需要连接到上面的服务器。

我发现在使用多个 heroku 应用程序 进行负载平衡的情况下,没有指定解决方案。我应该在第一台服务器中配置nginx.conf.erb文件以正确连接4个Heroku服务器吗?我尝试像这个链接http://nginx.org/en/docs/http/load_balancing.html 那样实现,但我只收到400 base request

【问题讨论】:

    标签: node.js performance nginx heroku load-balancing


    【解决方案1】:

    Heroku 循环负载平衡

    server {
        listen 80 default_server;
        server_name _;
        location / {
            set_formatted_local_time $upstream "%S";
            if ($upstream ~ 00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15) {
                set $backend_url http://phpmyadmin-heroku.herokuapp.com;
                set $backend_host phpmyadmin-heroku.herokuapp.com;
            }
            if ($upstream ~ 16|17|18|19|20|21|22|23|24|25|26|27|28|29|30) {
                set $backend_url https://helloenvoy.herokuapp.com;
                set $backend_host helloenvoy.herokuapp.com;
            }
            if ($upstream ~ 31|32|33|34|35|36|37|38|39|40|41|42|43|44|45) {
                set $backend_url http://powr.herokuapp.com;
                set $backend_host powr.herokuapp.com;
            }
            if ($upstream ~ 46|47|48|49|50|51|52|53|54|55|56|57|58|59) {
                set $backend_url https://blog.heroku.com;
                set $backend_host blog.heroku.com;
            }
            proxy_pass $backend_url;
            proxy_set_header Host $backend_host;
        }
        location /load_balancing_heroku_resolver1 {
            proxy_pass http://phpmyadmin-heroku.herokuapp.com;
        }
        location /load_balancing_heroku_resolver2 {
            proxy_pass https://helloenvoy.herokuapp.com;
        }
        location /load_balancing_heroku_resolver3 {
            proxy_pass http://powr.herokuapp.com;
        }
        location /load_balancing_heroku_resolver4 {
            proxy_pass https://blog.heroku.com;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-09-28
      • 1970-01-01
      • 2020-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-10
      • 2010-10-25
      • 2020-12-31
      相关资源
      最近更新 更多