Repository: stratos Updated Branches: refs/heads/stratos-4.1.x eacf5178c -> bc2d022d5
fixing upstream generation issue when there is no servers available Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/bc2d022d Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/bc2d022d Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/bc2d022d Branch: refs/heads/stratos-4.1.x Commit: bc2d022d5689b64a0c156555d5cccc2be09a7cbf Parents: 912a24a Author: reka <[email protected]> Authored: Tue Oct 13 13:23:54 2015 +0530 Committer: reka <[email protected]> Committed: Tue Oct 13 13:24:20 2015 +0530 ---------------------------------------------------------------------- .../src/main/templates/nginx.cfg.template | 84 ++++++++++---------- 1 file changed, 44 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/bc2d022d/extensions/load-balancer/modules/nginx-extension/src/main/templates/nginx.cfg.template ---------------------------------------------------------------------- diff --git a/extensions/load-balancer/modules/nginx-extension/src/main/templates/nginx.cfg.template b/extensions/load-balancer/modules/nginx-extension/src/main/templates/nginx.cfg.template index a26467e..dbd1b6b 100644 --- a/extensions/load-balancer/modules/nginx-extension/src/main/templates/nginx.cfg.template +++ b/extensions/load-balancer/modules/nginx-extension/src/main/templates/nginx.cfg.template @@ -7,49 +7,53 @@ http { server_names_hash_bucket_size 128; #set( $hostnameServerMap = $servermap.get($port.proxy) ) #foreach( $hostname in $hostnameServerMap.keySet() ) - upstream $hostname { - ## Uncomment below when sticky secession is needed by particular server - ##if( $$hostname == "group-scaling.my-c3-group2.stratos.apache.org" ) - ## sticky; - ###end #set ($servers = $hostnameServerMap.get($hostname) ) - #foreach ( $server in $servers) - server $server; - #end - } + #set ($noOfServers = $servers.size() ) + #if ( $noOfServers > 0) + upstream $hostname { + ## Uncomment below when sticky secession is needed by particular server + ##if( $$hostname == "group-scaling.my-c3-group2.stratos.apache.org" ) + ## sticky; + ###end + #set ($servers = $hostnameServerMap.get($hostname) ) + #foreach ( $server in $servers) + server $server; + #end + } - server { - #if ($port.protocol == "https") - listen $port.proxy ssl; - #else - listen $port.proxy; - #end - server_name $hostname; - location / { - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Server $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_read_timeout 5m; - proxy_send_timeout 5m; - #if ($port.protocol == "https") - proxy_pass https://$hostname; - #else - proxy_pass http://$hostname; + server { + #if ($port.protocol == "https") + listen $port.proxy ssl; + #else + listen $port.proxy; + #end + server_name $hostname; + location / { + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Server $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_read_timeout 5m; + proxy_send_timeout 5m; + #if ($port.protocol == "https") + proxy_pass https://$hostname; + #else + proxy_pass http://$hostname; + #end + } + location /nginx_status { + stub_status on; + access_log off; + allow 127.0.0.1; + deny all; + } + #if ($port.protocol == "https") + ssl on; + ssl_certificate /etc/nginx/ssl/server.cert; + ssl_certificate_key /etc/nginx/ssl/server.key; + #end + } #end - } - location /nginx_status { - stub_status on; - access_log off; - allow 127.0.0.1; - deny all; - } - #if ($port.protocol == "https") - ssl on; - ssl_certificate /etc/nginx/ssl/server.cert; - ssl_certificate_key /etc/nginx/ssl/server.key; #end - } -#end } #end
