Browse Source

Fix nginx ingress path for capture group (#752)

pull/756/head
Justin Kotalik 6 years ago
committed by GitHub
parent
commit
77ebc0d055
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/Microsoft.Tye.Core/KubernetesManifestGenerator.cs

13
src/Microsoft.Tye.Core/KubernetesManifestGenerator.cs

@ -92,14 +92,21 @@ namespace Microsoft.Tye
//
// Therefore our rewrite-target is set to $2 - we want to make sure we have
// two capture groups.
if (string.IsNullOrEmpty(ingressRule.Path) || ingressRule.Path == "/" || ingressRule.PreservePath)
if (string.IsNullOrEmpty(ingressRule.Path) || ingressRule.Path == "/")
{
path.Add("path", "/()(.*)"); // () is an empty capture group.
}
else
{
var regex = $"{ingressRule.Path.TrimEnd('/')}(/|$)(.*)";
path.Add("path", regex);
if (ingressRule.PreservePath)
{
path.Add("path", $"/()({ingressRule.Path.Trim('/')}.*)");
}
else
{
var regex = $"{ingressRule.Path.TrimEnd('/')}(/|$)(.*)";
path.Add("path", regex);
}
}
}
}

Loading…
Cancel
Save