</code></pre></div><p>This should have created a Deployment and a Service with the name <code>nginx-errors</code>.</p><divclass=highlight><pre><span></span><code>$ kubectl get deploy,svc
</code></pre></div><h2id=ingress-controller-configuration>Ingress controller configuration<aclass=headerlinkhref=#ingress-controller-configurationtitle="Permanent link"> ¶</a></h2><p>If you do not already have an instance of the NGINX Ingress controller running, deploy it according to the <ahref=../../../deploy/>deployment guide</a>, then follow these steps:</p><ol><li><p>Edit the <code>ingress-nginx-controller</code> Deployment and set the value of the <code>--default-backend-service</code> flag to the name of the newly created error backend.</p></li><li><p>Edit the <code>ingress-nginx-controller</code> ConfigMap and create the key <code>custom-http-errors</code> with a value of <code>404,503</code>.</p></li><li><p>Take note of the IP address assigned to the NGINX Ingress controller Service. <divclass=highlight><pre><span></span><code>$ kubectl get svc ingress-nginx
</code></pre></div></p></li></ol><divclass="admonition note"><pclass=admonition-title>Note</p><p>The <code>ingress-nginx</code> Service is of type <code>ClusterIP</code> in this example. This may vary depending on your environment. Make sure you can use the Service to reach NGINX before proceeding with the rest of this example.</p></div><h2id=testing-error-pages>Testing error pages<aclass=headerlinkhref=#testing-error-pagestitle="Permanent link"> ¶</a></h2><p>Let us send a couple of HTTP requests using cURL and validate everything is working as expected.</p><p>A request to the default backend returns a 404 error with a custom message:</p><divclass=highlight><pre><span></span><code>$ curl -D- http://10.0.0.13/
</code></pre></div><p>A request with a custom <code>Accept</code> header returns the corresponding document type (JSON):</p><divclass=highlight><pre><span></span><code>$ curl -D- -H 'Accept: application/json' http://10.0.0.13/
</code></pre></div><p>To go further with this example, feel free to deploy your own applications and Ingress objects, and validate that the responses are still in the correct format when a backend returns 503 (eg. if you scale a Deployment down to 0 replica).</p></article></div></div></main><footerclass=md-footer><divclass=md-footer-nav><navclass="md-footer-nav__inner md-grid"aria-label=Footer><ahref=../custom-configuration/class="md-footer-nav__link md-footer-nav__link--prev"rel=prev><divclass="md-footer-nav__button md-icon"><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg></div><divclass=md-footer-nav__title><divclass=md-ellipsis><spanclass=md-footer-nav__direction> Previous </span> Custom Configuration </div></div></a><ahref=../custom-headers/class="md-footer-nav__link md-footer-nav__link--next"rel=next><divclass=md-footer-nav__title><divclass=md-ellipsis><spanclass=md-footer-nav__direction> Next </span> Custom Headers </div></div><divclass="md-footer-nav__button md-icon"><svgxmlns=http://www.w3.org/2000/svgviewbox="0 0 24 24"><pathd="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4z"/></svg></div></a></nav></div><divclass="md-footer-meta md-typeset"><divclass="md-footer-meta__inner md-grid"><divclass=md-footer-copyright> Made with <ahref=https://squidfunk.github.io/mkdocs-material/target=_blankrel=noopener> Material for MkDocs </a></div></div></div></footer></div><scriptsrc=../../../assets/javascripts/vendor.93c04032.min.js></script><scriptsrc=../../../assets/javascripts/bundle.83e5331e.min.js></script><scriptid=__langtype=application/json>{"clipboard.copy":"Copy to clipboard","clipboard.copied":"Copied to clipboard","search.config.lang":"en","search.config.pipeline":"trimmer, stopWordFilter","search.config.separator":"[\\s\\-]+","search.placeholder":"Search","search.result.placeholder":"Type to start searching","search.result.none":"No matching documents","search.result.one":"1 matching document","search.result.other":"# matching documents","search.result.more.one":"1 more on this page","search.result.more.other":"# more on this page","search.result.term.missing":"Missing"}</script><script>