Answers: <p>There is no built-in configuration/annotation to handle this.</p>
  <p>Although, you can use the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#server-snippet" rel="nofollow noreferrer">server-snippet</a> annotation to create a custom configuration that <a href="http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors" rel="nofollow noreferrer">intercepts</a> the error 503, proxying the request to a service that is serving your custom error page. Example:</p>
  <pre><code>apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: ingress
    annotations:
      kubernetes.io/ingress.class: &quot;nginx&quot;
      nginx.ingress.kubernetes.io/server-snippet: |
        proxy_intercept_errors on;
        error_page 503 = @errorpages;
        
        location @errorpages {
          proxy_set_header X-Code $status;
          proxy_pass http://errors-svc.default.svc.cluster.local;
        }
  spec:
    rules:
    - host: ameba.example.com
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: nginx
              port:
                number: 80
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-06-27T14:32:57.927Z
Answers: I was stuck in how to pass the service to proxy_pass, thanks ;)
Answers: Rez Moss
Answers: CC BY-SA 4.0
Answers: 2021-03-30T16:42:21.250Z
Answers: 2021-03-30T16:42:21.250Z
Answers: Eduardo Baitello
Body: <p>When our site is getting deployed, the Ingress gets created and before I could get any response I get 503 for 5-6 minutes (time taken to startup).</p>
  <p>We need to configure our ingress to redirect to a static page that is custom-made instead of the 503 error. Can I add an annotation to achieve this? If yes, please give me an example for redirect config using the status code.</p>
  
Tags: <amazon-web-services><kubernetes><load-balance><ingress>
Title: Redirect to a custom page on 503 error in Ingress
UserDisplayName: Sri Krishna
ThreadText: # Redirect to a custom page on 503 error in Ingress
  
  (Asked by: username_0 on 2020-12-11)
  
  When our site is getting deployed, the Ingress gets created and before I could get any response I get 503 for 5-6 minutes (time taken to startup).
  
  We need to configure our ingress to redirect to a static page that is custom-made instead of the 503 error. Can I add an annotation to achieve this? If yes, please give me an example for redirect config using the status code.
  
  **Tags:** amazon-web-services, kubernetes, load-balance, ingress
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-03-30. Score: 2
  
  There is no built-in configuration/annotation to handle this.
  
  Although, you can use the [server-snippet](https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#server-snippet) annotation to create a custom configuration that [intercepts](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors) the error 503, proxying the request to a service that is serving your custom error page. Example:
  
  ```
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: ingress
    annotations:
      kubernetes.io/ingress.class: "nginx"
      nginx.ingress.kubernetes.io/server-snippet: |
        proxy_intercept_errors on;
        error_page 503 = @errorpages;
        
        location @errorpages {
          proxy_set_header X-Code $status;
          proxy_pass http://errors-svc.default.svc.cluster.local;
        }
  spec:
    rules:
    - host: ameba.example.com
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: nginx
              port:
                number: 80
  
  ```
  
  > **Comments:**
  > **username_2**: I was stuck in how to pass the service to proxy_pass, thanks ;)  
  
  ---
  
  