pkg/router/route.conf
{{range $port := .Ports}}
{{range $version := $.Versions}}
upstream {{$.Service}}-kt-mesh-{{$version}}-{{index $port 0}} {
server {{$.Service}}-kt-mesh-{{$version}}:{{index $port 0}};
}
{{end}}
upstream {{$.Service}}-kt-stuntman-{{index $port 0}} {
server {{$.Service}}-kt-stuntman:{{index $port 0}};
}
{{end}}
{{range $port := .Ports}}
server {
listen {{index $port 1}};
listen [::]:{{index $port 1}};
server_name {{$.Service}};
underscores_in_headers on;
proxy_intercept_errors off;
error_page 500 /kt_nginx_error_500;
error_page 502 /kt_nginx_error_502;
error_page 503 /kt_nginx_error_503;
error_page 504 /kt_nginx_error_504;
location = /kt_nginx_error_500 {
return 500 "500 - KtConnect mesh internal error";
}
location = /kt_nginx_error_502 {
return 502 "502 - KtConnect mesh connection error";
}
location = /kt_nginx_error_503 {
return 503 "503 - KtConnect mesh temporary error";
}
location = /kt_nginx_error_504 {
return 504 "504 - KtConnect mesh connection timeout";
}
location / {
proxy_redirect off;
proxy_http_version 1.1;
{{range $version := $.Versions}}
if ($http_{{$.Header}} = "{{$version}}") {
proxy_pass http://{{$.Service}}-kt-mesh-{{$version}}-{{index $port 0}};
}
{{end}}
proxy_pass http://{{$.Service}}-kt-stuntman-{{index $port 0}};
}
}
{{end}}