How do I set up domain redirects in Porter?

Last updated: February 9, 2026

Context

When running applications in Porter, you may want to set up redirects from one domain to another. For example, you might want to redirect traffic from an old domain to a new one while maintaining the original request path.

Answer

You can set up domain redirects in Porter by adding an ingress annotation to your application configuration. This is done using the nginx.ingress.kubernetes.io/server-snippet annotation.

To redirect one domain to another:

  1. Add the following ingress annotation to your application configuration:

nginx.ingress.kubernetes.io/server-snippet: if ($host ~ "old-domain.com") { rewrite ^ https://new-domain.com$request_uri permanent;}

For example, to redirect a.example.com to b.example.com, use:

nginx.ingress.kubernetes.io/server-snippet: if ($host ~ "a.example.com") { rewrite ^ https://b.example.com$request_uri permanent;}

The redirect will be permanent (HTTP 301) and will preserve any path or query parameters from the original request.