我需要设计一个需要的系统:
1 Node.js Server用于反向代理,使用Nginx进行负载均衡。
4 Node.js Server用于RESTful API。所有这些都需要连接到上面的服务器。
我发现在使用多个 heroku应用进行负载均衡时,没有指定解决方案。我应该在第一台服务器中配置nginx.conf.erb
文件以正确的方式连接4个Heroku服务器?我尝试按照此链接http://nginx.org/en/docs/http/load_balancing.html进行实施,但我只收到400 base request
。
答案 0 :(得分:0)
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;
}
}