Skip to content
Permalink
Browse files

Declare link consumed and use it to configure load balancing.

  • Loading branch information...
krasio committed Feb 10, 2019
1 parent 8f8be18 commit eb1af8eb8c636b18dff70947c4fd9821744257f0
Showing with 15 additions and 2 deletions.
  1. +6 −1 jobs/nginx/spec
  2. +9 −1 jobs/nginx/templates/{nginx.conf → nginx.conf.erb}
@@ -3,9 +3,14 @@ name: nginx

templates:
ctl.erb: bin/ctl
nginx.conf: conf/nginx.conf
nginx.conf.erb: conf/nginx.conf

packages:
- nginx-1.14


consumes:
- name: backend_servers
type: http

properties: {}
@@ -14,10 +14,18 @@ http {
keepalive_timeout 65;
server_names_hash_bucket_size 512;

upstream backend {
<%- link("backend_servers").instances.each do |instance| -%>
server <%= instance.address -%>:8080;
<%- end -%>
}

server {
listen 80;
access_log /var/vcap/sys/log/nginx/access.log;

return 200 "\nKia Ora!\n";
location / {
proxy_pass http://backend;
}
}
}

0 comments on commit eb1af8e

Please sign in to comment.
You can’t perform that action at this time.