ingress-nginx-helm/user-guide/nginx-configuration/annotations/index.html
2025-01-17 08:38:47 +00:00

77 lines
No EOL
123 KiB
HTML

<!doctype html><html lang=en class=no-js> <head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link href=https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/ rel=canonical><link href=../../basic-usage/ rel=prev><link href=../annotations-risk/ rel=next><link rel=icon href=../../../assets/images/favicon.png><meta name=generator content="mkdocs-1.5.3, mkdocs-material-9.4.5"><title>Annotations - Ingress-Nginx Controller</title><link rel=stylesheet href=../../../assets/stylesheets/main.6a10b989.min.css><link rel=stylesheet href=../../../assets/stylesheets/palette.356b1318.min.css><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback"><style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style><link rel=stylesheet href=../../../extra.css><script>__md_scope=new URL("../../..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script></head> <body dir=ltr data-md-color-scheme=default data-md-color-primary=teal data-md-color-accent=green> <input class=md-toggle data-md-toggle=drawer type=checkbox id=__drawer autocomplete=off> <input class=md-toggle data-md-toggle=search type=checkbox id=__search autocomplete=off> <label class=md-overlay for=__drawer></label> <div data-md-component=skip> <a href=#annotations class=md-skip> Skip to content </a> </div> <div data-md-component=announce> </div> <header class="md-header md-header--shadow md-header--lifted" data-md-component=header> <nav class="md-header__inner md-grid" aria-label=Header> <a href=../../.. title="Ingress-Nginx Controller" class="md-header__button md-logo" aria-label="Ingress-Nginx Controller" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"/></svg> </a> <label class="md-header__button md-icon" for=__drawer> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg> </label> <div class=md-header__title data-md-component=header-title> <div class=md-header__ellipsis> <div class=md-header__topic> <span class=md-ellipsis> Ingress-Nginx Controller </span> </div> <div class=md-header__topic data-md-component=header-topic> <span class=md-ellipsis> Annotations </span> </div> </div> </div> <label class="md-header__button md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg> </label> <div class=md-search data-md-component=search role=dialog> <label class=md-search__overlay for=__search></label> <div class=md-search__inner role=search> <form class=md-search__form name=search> <input type=text class=md-search__input name=query aria-label=Search placeholder=Search autocapitalize=off autocorrect=off autocomplete=off spellcheck=false data-md-component=search-query required> <label class="md-search__icon md-icon" for=__search> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg> </label> <nav class=md-search__options aria-label=Search> <button type=reset class="md-search__icon md-icon" title=Clear aria-label=Clear tabindex=-1> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg> </button> </nav> </form> <div class=md-search__output> <div class=md-search__scrollwrap data-md-scrollfix> <div class=md-search-result data-md-component=search-result> <div class=md-search-result__meta> Initializing search </div> <ol class=md-search-result__list role=presentation></ol> </div> </div> </div> </div> </div> <div class=md-header__source> <a href=https://github.com/kubernetes/ingress-nginx title="Go to repository" class=md-source data-md-component=source> <div class="md-source__icon md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg> </div> <div class=md-source__repository> kubernetes/ingress-nginx </div> </a> </div> </nav> <nav class=md-tabs aria-label=Tabs data-md-component=tabs> <div class=md-grid> <ul class=md-tabs__list> <li class=md-tabs__item> <a href=../../.. class=md-tabs__link> Welcome </a> </li> <li class=md-tabs__item> <a href=../../../deploy/ class=md-tabs__link> Deployment </a> </li> <li class="md-tabs__item md-tabs__item--active"> <a href=../ class=md-tabs__link> User Guide </a> </li> <li class=md-tabs__item> <a href=../../../examples/ class=md-tabs__link> Examples </a> </li> <li class=md-tabs__item> <a href=../../../developer-guide/getting-started/ class=md-tabs__link> Developer Guide </a> </li> <li class=md-tabs__item> <a href=../../../faq/ class=md-tabs__link> FAQ </a> </li> </ul> </div> </nav> </header> <div class=md-container data-md-component=container> <main class=md-main data-md-component=main> <div class="md-main__inner md-grid"> <div class="md-sidebar md-sidebar--primary" data-md-component=sidebar data-md-type=navigation> <div class=md-sidebar__scrollwrap> <div class=md-sidebar__inner> <nav class="md-nav md-nav--primary md-nav--lifted" aria-label=Navigation data-md-level=0> <label class=md-nav__title for=__drawer> <a href=../../.. title="Ingress-Nginx Controller" class="md-nav__button md-logo" aria-label="Ingress-Nginx Controller" data-md-component=logo> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54Z"/></svg> </a> Ingress-Nginx Controller </label> <div class=md-nav__source> <a href=https://github.com/kubernetes/ingress-nginx title="Go to repository" class=md-source data-md-component=source> <div class="md-source__icon md-icon"> <svg xmlns=http://www.w3.org/2000/svg viewbox="0 0 448 512"><!-- Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg> </div> <div class=md-source__repository> kubernetes/ingress-nginx </div> </a> </div> <ul class=md-nav__list data-md-scrollfix> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_1> <label class=md-nav__link for=__nav_1 id=__nav_1_label tabindex> <span class=md-ellipsis> Welcome </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_1_label aria-expanded=false> <label class=md-nav__title for=__nav_1> <span class="md-nav__icon md-icon"></span> Welcome </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../.. class=md-nav__link> <span class=md-ellipsis> Welcome </span> </a> </li> <li class=md-nav__item> <a href=../../../how-it-works/ class=md-nav__link> <span class=md-ellipsis> How it works </span> </a> </li> <li class=md-nav__item> <a href=../../../troubleshooting/ class=md-nav__link> <span class=md-ellipsis> Troubleshooting </span> </a> </li> <li class=md-nav__item> <a href=../../../kubectl-plugin/ class=md-nav__link> <span class=md-ellipsis> kubectl plugin </span> </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_2> <label class=md-nav__link for=__nav_2 id=__nav_2_label tabindex> <span class=md-ellipsis> Deployment </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_2_label aria-expanded=false> <label class=md-nav__title for=__nav_2> <span class="md-nav__icon md-icon"></span> Deployment </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../deploy/ class=md-nav__link> <span class=md-ellipsis> Installation Guide </span> </a> </li> <li class=md-nav__item> <a href=../../../deploy/baremetal/ class=md-nav__link> <span class=md-ellipsis> Bare-metal considerations </span> </a> </li> <li class=md-nav__item> <a href=../../../deploy/rbac/ class=md-nav__link> <span class=md-ellipsis> Role Based Access Control (RBAC) </span> </a> </li> <li class=md-nav__item> <a href=../../../deploy/upgrade/ class=md-nav__link> <span class=md-ellipsis> Upgrade </span> </a> </li> <li class=md-nav__item> <a href=../../../deploy/hardening-guide/ class=md-nav__link> <span class=md-ellipsis> Hardening guide </span> </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_3 checked> <label class=md-nav__link for=__nav_3 id=__nav_3_label tabindex> <span class=md-ellipsis> User Guide </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_3_label aria-expanded=true> <label class=md-nav__title for=__nav_3> <span class="md-nav__icon md-icon"></span> User Guide </label> <ul class=md-nav__list data-md-scrollfix> <li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_3_1 checked> <label class=md-nav__link for=__nav_3_1 id=__nav_3_1_label tabindex> <span class=md-ellipsis> NGINX Configuration </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=2 aria-labelledby=__nav_3_1_label aria-expanded=true> <label class=md-nav__title for=__nav_3_1> <span class="md-nav__icon md-icon"></span> NGINX Configuration </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../ class=md-nav__link> <span class=md-ellipsis> Introduction </span> </a> </li> <li class=md-nav__item> <a href=../../basic-usage/ class=md-nav__link> <span class=md-ellipsis> Basic usage </span> </a> </li> <li class="md-nav__item md-nav__item--active"> <input class="md-nav__toggle md-toggle" type=checkbox id=__toc> <label class="md-nav__link md-nav__link--active" for=__toc> <span class=md-ellipsis> Annotations </span> <span class="md-nav__icon md-icon"></span> </label> <a href=./ class="md-nav__link md-nav__link--active"> <span class=md-ellipsis> Annotations </span> </a> <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> <label class=md-nav__title for=__toc> <span class="md-nav__icon md-icon"></span> Table of contents </label> <ul class=md-nav__list data-md-component=toc data-md-scrollfix> <li class=md-nav__item> <a href=#canary class=md-nav__link> Canary </a> </li> <li class=md-nav__item> <a href=#rewrite class=md-nav__link> Rewrite </a> </li> <li class=md-nav__item> <a href=#session-affinity class=md-nav__link> Session Affinity </a> <nav class=md-nav aria-label="Session Affinity"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#cookie-affinity class=md-nav__link> Cookie affinity </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#authentication class=md-nav__link> Authentication </a> </li> <li class=md-nav__item> <a href=#custom-nginx-upstream-hashing class=md-nav__link> Custom NGINX upstream hashing </a> </li> <li class=md-nav__item> <a href=#custom-nginx-load-balancing class=md-nav__link> Custom NGINX load balancing </a> </li> <li class=md-nav__item> <a href=#custom-nginx-upstream-vhost class=md-nav__link> Custom NGINX upstream vhost </a> </li> <li class=md-nav__item> <a href=#client-certificate-authentication class=md-nav__link> Client Certificate Authentication </a> </li> <li class=md-nav__item> <a href=#backend-certificate-authentication class=md-nav__link> Backend Certificate Authentication </a> </li> <li class=md-nav__item> <a href=#configuration-snippet class=md-nav__link> Configuration snippet </a> </li> <li class=md-nav__item> <a href=#custom-http-errors class=md-nav__link> Custom HTTP Errors </a> </li> <li class=md-nav__item> <a href=#custom-headers class=md-nav__link> Custom Headers </a> </li> <li class=md-nav__item> <a href=#default-backend class=md-nav__link> Default Backend </a> </li> <li class=md-nav__item> <a href=#enable-cors class=md-nav__link> Enable CORS </a> </li> <li class=md-nav__item> <a href=#http2-push-preload class=md-nav__link> HTTP2 Push Preload. </a> </li> <li class=md-nav__item> <a href=#server-alias class=md-nav__link> Server Alias </a> </li> <li class=md-nav__item> <a href=#server-snippet class=md-nav__link> Server snippet </a> </li> <li class=md-nav__item> <a href=#client-body-buffer-size class=md-nav__link> Client Body Buffer Size </a> </li> <li class=md-nav__item> <a href=#external-authentication class=md-nav__link> External Authentication </a> <nav class=md-nav aria-label="External Authentication"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#global-external-authentication class=md-nav__link> Global External Authentication </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#rate-limiting class=md-nav__link> Rate Limiting </a> </li> <li class=md-nav__item> <a href=#permanent-redirect class=md-nav__link> Permanent Redirect </a> </li> <li class=md-nav__item> <a href=#permanent-redirect-code class=md-nav__link> Permanent Redirect Code </a> </li> <li class=md-nav__item> <a href=#temporal-redirect class=md-nav__link> Temporal Redirect </a> </li> <li class=md-nav__item> <a href=#temporal-redirect-code class=md-nav__link> Temporal Redirect Code </a> </li> <li class=md-nav__item> <a href=#ssl-passthrough class=md-nav__link> SSL Passthrough </a> </li> <li class=md-nav__item> <a href=#service-upstream class=md-nav__link> Service Upstream </a> <nav class=md-nav aria-label="Service Upstream"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#known-issues class=md-nav__link> Known Issues </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#server-side-https-enforcement-through-redirect class=md-nav__link> Server-side HTTPS enforcement through redirect </a> </li> <li class=md-nav__item> <a href=#redirect-fromto-www class=md-nav__link> Redirect from/to www </a> </li> <li class=md-nav__item> <a href=#denylist-source-range class=md-nav__link> Denylist source range </a> </li> <li class=md-nav__item> <a href=#whitelist-source-range class=md-nav__link> Whitelist source range </a> </li> <li class=md-nav__item> <a href=#custom-timeouts class=md-nav__link> Custom timeouts </a> </li> <li class=md-nav__item> <a href=#proxy-redirect class=md-nav__link> Proxy redirect </a> </li> <li class=md-nav__item> <a href=#custom-max-body-size class=md-nav__link> Custom max body size </a> </li> <li class=md-nav__item> <a href=#proxy-cookie-domain class=md-nav__link> Proxy cookie domain </a> </li> <li class=md-nav__item> <a href=#proxy-cookie-path class=md-nav__link> Proxy cookie path </a> </li> <li class=md-nav__item> <a href=#proxy-buffering class=md-nav__link> Proxy buffering </a> </li> <li class=md-nav__item> <a href=#proxy-buffers-number class=md-nav__link> Proxy buffers Number </a> </li> <li class=md-nav__item> <a href=#proxy-buffer-size class=md-nav__link> Proxy buffer size </a> </li> <li class=md-nav__item> <a href=#proxy-busy-buffers-size class=md-nav__link> Proxy busy buffers size </a> </li> <li class=md-nav__item> <a href=#proxy-max-temp-file-size class=md-nav__link> Proxy max temp file size </a> </li> <li class=md-nav__item> <a href=#proxy-http-version class=md-nav__link> Proxy HTTP version </a> </li> <li class=md-nav__item> <a href=#ssl-ciphers class=md-nav__link> SSL ciphers </a> </li> <li class=md-nav__item> <a href=#connection-proxy-header class=md-nav__link> Connection proxy header </a> </li> <li class=md-nav__item> <a href=#enable-access-log class=md-nav__link> Enable Access Log </a> </li> <li class=md-nav__item> <a href=#enable-rewrite-log class=md-nav__link> Enable Rewrite Log </a> </li> <li class=md-nav__item> <a href=#enable-opentelemetry class=md-nav__link> Enable Opentelemetry </a> </li> <li class=md-nav__item> <a href=#opentelemetry-trust-incoming-span class=md-nav__link> Opentelemetry Trust Incoming Span </a> </li> <li class=md-nav__item> <a href=#x-forwarded-prefix-header class=md-nav__link> X-Forwarded-Prefix Header </a> </li> <li class=md-nav__item> <a href=#modsecurity class=md-nav__link> ModSecurity </a> </li> <li class=md-nav__item> <a href=#backend-protocol class=md-nav__link> Backend Protocol </a> </li> <li class=md-nav__item> <a href=#use-regex class=md-nav__link> Use Regex </a> </li> <li class=md-nav__item> <a href=#satisfy class=md-nav__link> Satisfy </a> </li> <li class=md-nav__item> <a href=#mirror class=md-nav__link> Mirror </a> </li> <li class=md-nav__item> <a href=#stream-snippet class=md-nav__link> Stream snippet </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../annotations-risk/ class=md-nav__link> <span class=md-ellipsis> Annotations Risks </span> </a> </li> <li class=md-nav__item> <a href=../configmap/ class=md-nav__link> <span class=md-ellipsis> ConfigMap </span> </a> </li> <li class=md-nav__item> <a href=../custom-template/ class=md-nav__link> <span class=md-ellipsis> Custom NGINX template </span> </a> </li> <li class=md-nav__item> <a href=../log-format/ class=md-nav__link> <span class=md-ellipsis> Log format </span> </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../../cli-arguments/ class=md-nav__link> <span class=md-ellipsis> Command line arguments </span> </a> </li> <li class=md-nav__item> <a href=../../custom-errors/ class=md-nav__link> <span class=md-ellipsis> Custom errors </span> </a> </li> <li class=md-nav__item> <a href=../../default-backend/ class=md-nav__link> <span class=md-ellipsis> Default backend </span> </a> </li> <li class=md-nav__item> <a href=../../exposing-tcp-udp-services/ class=md-nav__link> <span class=md-ellipsis> Exposing TCP and UDP services </span> </a> </li> <li class=md-nav__item> <a href=../../fcgi-services/ class=md-nav__link> <span class=md-ellipsis> Exposing FCGI services </span> </a> </li> <li class=md-nav__item> <a href=../../ingress-path-matching/ class=md-nav__link> <span class=md-ellipsis> Regular expressions in paths </span> </a> </li> <li class=md-nav__item> <a href=../../external-articles/ class=md-nav__link> <span class=md-ellipsis> External Articles </span> </a> </li> <li class=md-nav__item> <a href=../../miscellaneous/ class=md-nav__link> <span class=md-ellipsis> Miscellaneous </span> </a> </li> <li class=md-nav__item> <a href=../../monitoring/ class=md-nav__link> <span class=md-ellipsis> Prometheus and Grafana installation </span> </a> </li> <li class=md-nav__item> <a href=../../multiple-ingress/ class=md-nav__link> <span class=md-ellipsis> Multiple Ingress controllers </span> </a> </li> <li class=md-nav__item> <a href=../../tls/ class=md-nav__link> <span class=md-ellipsis> TLS/HTTPS </span> </a> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_3_13> <label class=md-nav__link for=__nav_3_13 id=__nav_3_13_label tabindex> <span class=md-ellipsis> Third party addons </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=2 aria-labelledby=__nav_3_13_label aria-expanded=false> <label class=md-nav__title for=__nav_3_13> <span class="md-nav__icon md-icon"></span> Third party addons </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../third-party-addons/modsecurity/ class=md-nav__link> <span class=md-ellipsis> ModSecurity Web Application Firewall </span> </a> </li> <li class=md-nav__item> <a href=../../third-party-addons/opentelemetry/ class=md-nav__link> <span class=md-ellipsis> OpenTelemetry </span> </a> </li> </ul> </nav> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_4> <label class=md-nav__link for=__nav_4 id=__nav_4_label tabindex> <span class=md-ellipsis> Examples </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_4_label aria-expanded=false> <label class=md-nav__title for=__nav_4> <span class="md-nav__icon md-icon"></span> Examples </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../examples/ class=md-nav__link> <span class=md-ellipsis> Introduction </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/PREREQUISITES/ class=md-nav__link> <span class=md-ellipsis> Prerequisites </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/affinity/cookie/ class=md-nav__link> <span class=md-ellipsis> Sticky Sessions </span> </a> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_4_4> <label class=md-nav__link for=__nav_4_4 id=__nav_4_4_label tabindex> <span class=md-ellipsis> Auth </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=2 aria-labelledby=__nav_4_4_label aria-expanded=false> <label class=md-nav__title for=__nav_4_4> <span class="md-nav__icon md-icon"></span> Auth </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../examples/auth/basic/ class=md-nav__link> <span class=md-ellipsis> Basic Authentication </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/auth/client-certs/ class=md-nav__link> <span class=md-ellipsis> Client Certificate Authentication </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/auth/external-auth/ class=md-nav__link> <span class=md-ellipsis> External Basic Authentication </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/auth/oauth-external-auth/ class=md-nav__link> <span class=md-ellipsis> External OAUTH Authentication </span> </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_4_5> <label class=md-nav__link for=__nav_4_5 id=__nav_4_5_label tabindex> <span class=md-ellipsis> Customization </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=2 aria-labelledby=__nav_4_5_label aria-expanded=false> <label class=md-nav__title for=__nav_4_5> <span class="md-nav__icon md-icon"></span> Customization </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../examples/customization/configuration-snippets/ class=md-nav__link> <span class=md-ellipsis> Configuration Snippets </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/customization/custom-configuration/ class=md-nav__link> <span class=md-ellipsis> Custom Configuration </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/customization/custom-errors/ class=md-nav__link> <span class=md-ellipsis> Custom Errors </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/customization/custom-headers/ class=md-nav__link> <span class=md-ellipsis> Custom Headers </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/customization/external-auth-headers/ class=md-nav__link> <span class=md-ellipsis> External authentication </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/customization/ssl-dh-param/ class=md-nav__link> <span class=md-ellipsis> Custom DH parameters for perfect forward secrecy </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/customization/sysctl/ class=md-nav__link> <span class=md-ellipsis> Sysctl tuning </span> </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../../../examples/docker-registry/ class=md-nav__link> <span class=md-ellipsis> Docker registry </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/grpc/ class=md-nav__link> <span class=md-ellipsis> gRPC </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/multi-tls/ class=md-nav__link> <span class=md-ellipsis> Multi TLS certificate termination </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/rewrite/ class=md-nav__link> <span class=md-ellipsis> Rewrite </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/static-ip/ class=md-nav__link> <span class=md-ellipsis> Static IPs </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/tls-termination/ class=md-nav__link> <span class=md-ellipsis> TLS termination </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/openpolicyagent/ class=md-nav__link> <span class=md-ellipsis> Open Policy Agent rules </span> </a> </li> <li class=md-nav__item> <a href=../../../examples/canary/ class=md-nav__link> <span class=md-ellipsis> Canary Deployments </span> </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--section md-nav__item--nested"> <input class="md-nav__toggle md-toggle " type=checkbox id=__nav_5> <label class=md-nav__link for=__nav_5 id=__nav_5_label tabindex> <span class=md-ellipsis> Developer Guide </span> <span class="md-nav__icon md-icon"></span> </label> <nav class=md-nav data-md-level=1 aria-labelledby=__nav_5_label aria-expanded=false> <label class=md-nav__title for=__nav_5> <span class="md-nav__icon md-icon"></span> Developer Guide </label> <ul class=md-nav__list data-md-scrollfix> <li class=md-nav__item> <a href=../../../developer-guide/getting-started/ class=md-nav__link> <span class=md-ellipsis> Getting Started </span> </a> </li> <li class=md-nav__item> <a href=../../../developer-guide/code-overview/ class=md-nav__link> <span class=md-ellipsis> Code Overview </span> </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=../../../faq/ class=md-nav__link> <span class=md-ellipsis> FAQ </span> </a> </li> </ul> </nav> </div> </div> </div> <div class="md-sidebar md-sidebar--secondary" data-md-component=sidebar data-md-type=toc> <div class=md-sidebar__scrollwrap> <div class=md-sidebar__inner> <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> <label class=md-nav__title for=__toc> <span class="md-nav__icon md-icon"></span> Table of contents </label> <ul class=md-nav__list data-md-component=toc data-md-scrollfix> <li class=md-nav__item> <a href=#canary class=md-nav__link> Canary </a> </li> <li class=md-nav__item> <a href=#rewrite class=md-nav__link> Rewrite </a> </li> <li class=md-nav__item> <a href=#session-affinity class=md-nav__link> Session Affinity </a> <nav class=md-nav aria-label="Session Affinity"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#cookie-affinity class=md-nav__link> Cookie affinity </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#authentication class=md-nav__link> Authentication </a> </li> <li class=md-nav__item> <a href=#custom-nginx-upstream-hashing class=md-nav__link> Custom NGINX upstream hashing </a> </li> <li class=md-nav__item> <a href=#custom-nginx-load-balancing class=md-nav__link> Custom NGINX load balancing </a> </li> <li class=md-nav__item> <a href=#custom-nginx-upstream-vhost class=md-nav__link> Custom NGINX upstream vhost </a> </li> <li class=md-nav__item> <a href=#client-certificate-authentication class=md-nav__link> Client Certificate Authentication </a> </li> <li class=md-nav__item> <a href=#backend-certificate-authentication class=md-nav__link> Backend Certificate Authentication </a> </li> <li class=md-nav__item> <a href=#configuration-snippet class=md-nav__link> Configuration snippet </a> </li> <li class=md-nav__item> <a href=#custom-http-errors class=md-nav__link> Custom HTTP Errors </a> </li> <li class=md-nav__item> <a href=#custom-headers class=md-nav__link> Custom Headers </a> </li> <li class=md-nav__item> <a href=#default-backend class=md-nav__link> Default Backend </a> </li> <li class=md-nav__item> <a href=#enable-cors class=md-nav__link> Enable CORS </a> </li> <li class=md-nav__item> <a href=#http2-push-preload class=md-nav__link> HTTP2 Push Preload. </a> </li> <li class=md-nav__item> <a href=#server-alias class=md-nav__link> Server Alias </a> </li> <li class=md-nav__item> <a href=#server-snippet class=md-nav__link> Server snippet </a> </li> <li class=md-nav__item> <a href=#client-body-buffer-size class=md-nav__link> Client Body Buffer Size </a> </li> <li class=md-nav__item> <a href=#external-authentication class=md-nav__link> External Authentication </a> <nav class=md-nav aria-label="External Authentication"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#global-external-authentication class=md-nav__link> Global External Authentication </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#rate-limiting class=md-nav__link> Rate Limiting </a> </li> <li class=md-nav__item> <a href=#permanent-redirect class=md-nav__link> Permanent Redirect </a> </li> <li class=md-nav__item> <a href=#permanent-redirect-code class=md-nav__link> Permanent Redirect Code </a> </li> <li class=md-nav__item> <a href=#temporal-redirect class=md-nav__link> Temporal Redirect </a> </li> <li class=md-nav__item> <a href=#temporal-redirect-code class=md-nav__link> Temporal Redirect Code </a> </li> <li class=md-nav__item> <a href=#ssl-passthrough class=md-nav__link> SSL Passthrough </a> </li> <li class=md-nav__item> <a href=#service-upstream class=md-nav__link> Service Upstream </a> <nav class=md-nav aria-label="Service Upstream"> <ul class=md-nav__list> <li class=md-nav__item> <a href=#known-issues class=md-nav__link> Known Issues </a> </li> </ul> </nav> </li> <li class=md-nav__item> <a href=#server-side-https-enforcement-through-redirect class=md-nav__link> Server-side HTTPS enforcement through redirect </a> </li> <li class=md-nav__item> <a href=#redirect-fromto-www class=md-nav__link> Redirect from/to www </a> </li> <li class=md-nav__item> <a href=#denylist-source-range class=md-nav__link> Denylist source range </a> </li> <li class=md-nav__item> <a href=#whitelist-source-range class=md-nav__link> Whitelist source range </a> </li> <li class=md-nav__item> <a href=#custom-timeouts class=md-nav__link> Custom timeouts </a> </li> <li class=md-nav__item> <a href=#proxy-redirect class=md-nav__link> Proxy redirect </a> </li> <li class=md-nav__item> <a href=#custom-max-body-size class=md-nav__link> Custom max body size </a> </li> <li class=md-nav__item> <a href=#proxy-cookie-domain class=md-nav__link> Proxy cookie domain </a> </li> <li class=md-nav__item> <a href=#proxy-cookie-path class=md-nav__link> Proxy cookie path </a> </li> <li class=md-nav__item> <a href=#proxy-buffering class=md-nav__link> Proxy buffering </a> </li> <li class=md-nav__item> <a href=#proxy-buffers-number class=md-nav__link> Proxy buffers Number </a> </li> <li class=md-nav__item> <a href=#proxy-buffer-size class=md-nav__link> Proxy buffer size </a> </li> <li class=md-nav__item> <a href=#proxy-busy-buffers-size class=md-nav__link> Proxy busy buffers size </a> </li> <li class=md-nav__item> <a href=#proxy-max-temp-file-size class=md-nav__link> Proxy max temp file size </a> </li> <li class=md-nav__item> <a href=#proxy-http-version class=md-nav__link> Proxy HTTP version </a> </li> <li class=md-nav__item> <a href=#ssl-ciphers class=md-nav__link> SSL ciphers </a> </li> <li class=md-nav__item> <a href=#connection-proxy-header class=md-nav__link> Connection proxy header </a> </li> <li class=md-nav__item> <a href=#enable-access-log class=md-nav__link> Enable Access Log </a> </li> <li class=md-nav__item> <a href=#enable-rewrite-log class=md-nav__link> Enable Rewrite Log </a> </li> <li class=md-nav__item> <a href=#enable-opentelemetry class=md-nav__link> Enable Opentelemetry </a> </li> <li class=md-nav__item> <a href=#opentelemetry-trust-incoming-span class=md-nav__link> Opentelemetry Trust Incoming Span </a> </li> <li class=md-nav__item> <a href=#x-forwarded-prefix-header class=md-nav__link> X-Forwarded-Prefix Header </a> </li> <li class=md-nav__item> <a href=#modsecurity class=md-nav__link> ModSecurity </a> </li> <li class=md-nav__item> <a href=#backend-protocol class=md-nav__link> Backend Protocol </a> </li> <li class=md-nav__item> <a href=#use-regex class=md-nav__link> Use Regex </a> </li> <li class=md-nav__item> <a href=#satisfy class=md-nav__link> Satisfy </a> </li> <li class=md-nav__item> <a href=#mirror class=md-nav__link> Mirror </a> </li> <li class=md-nav__item> <a href=#stream-snippet class=md-nav__link> Stream snippet </a> </li> </ul> </nav> </div> </div> </div> <div class=md-content data-md-component=content> <article class="md-content__inner md-typeset"> <h1 id=annotations>Annotations<a class=headerlink href=#annotations title="Permanent link"></a></h1> <p>You can add these Kubernetes annotations to specific Ingress objects to customize their behavior.</p> <div class="admonition tip"> <p class=admonition-title>Tip</p> <p>Annotation keys and values can only be strings. Other types, such as boolean or numeric values must be quoted, i.e. <code>"true"</code>, <code>"false"</code>, <code>"100"</code>.</p> </div> <div class="admonition note"> <p class=admonition-title>Note</p> <p>The annotation prefix can be changed using the <a href=../../cli-arguments/ ><code>--annotations-prefix</code> command line argument</a>, but the default is <code>nginx.ingress.kubernetes.io</code>, as described in the table below.</p> </div> <table> <thead> <tr> <th>Name</th> <th>type</th> </tr> </thead> <tbody> <tr> <td><a href=#rewrite>nginx.ingress.kubernetes.io/app-root</a></td> <td>string</td> </tr> <tr> <td><a href=#session-affinity>nginx.ingress.kubernetes.io/affinity</a></td> <td>cookie</td> </tr> <tr> <td><a href=#session-affinity>nginx.ingress.kubernetes.io/affinity-mode</a></td> <td>"balanced" or "persistent"</td> </tr> <tr> <td><a href=#session-affinity>nginx.ingress.kubernetes.io/affinity-canary-behavior</a></td> <td>"sticky" or "legacy"</td> </tr> <tr> <td><a href=#authentication>nginx.ingress.kubernetes.io/auth-realm</a></td> <td>string</td> </tr> <tr> <td><a href=#authentication>nginx.ingress.kubernetes.io/auth-secret</a></td> <td>string</td> </tr> <tr> <td><a href=#authentication>nginx.ingress.kubernetes.io/auth-secret-type</a></td> <td>string</td> </tr> <tr> <td><a href=#authentication>nginx.ingress.kubernetes.io/auth-type</a></td> <td>"basic" or "digest"</td> </tr> <tr> <td><a href=#client-certificate-authentication>nginx.ingress.kubernetes.io/auth-tls-secret</a></td> <td>string</td> </tr> <tr> <td><a href=#client-certificate-authentication>nginx.ingress.kubernetes.io/auth-tls-verify-depth</a></td> <td>number</td> </tr> <tr> <td><a href=#client-certificate-authentication>nginx.ingress.kubernetes.io/auth-tls-verify-client</a></td> <td>string</td> </tr> <tr> <td><a href=#client-certificate-authentication>nginx.ingress.kubernetes.io/auth-tls-error-page</a></td> <td>string</td> </tr> <tr> <td><a href=#client-certificate-authentication>nginx.ingress.kubernetes.io/auth-tls-pass-certificate-to-upstream</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#client-certificate-authentication>nginx.ingress.kubernetes.io/auth-tls-match-cn</a></td> <td>string</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-url</a></td> <td>string</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-cache-key</a></td> <td>string</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-cache-duration</a></td> <td>string</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-keepalive</a></td> <td>number</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-keepalive-share-vars</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-keepalive-requests</a></td> <td>number</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-keepalive-timeout</a></td> <td>number</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-proxy-set-headers</a></td> <td>string</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/auth-snippet</a></td> <td>string</td> </tr> <tr> <td><a href=#external-authentication>nginx.ingress.kubernetes.io/enable-global-auth</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#backend-protocol>nginx.ingress.kubernetes.io/backend-protocol</a></td> <td>string</td> </tr> <tr> <td><a href=#canary>nginx.ingress.kubernetes.io/canary</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#canary>nginx.ingress.kubernetes.io/canary-by-header</a></td> <td>string</td> </tr> <tr> <td><a href=#canary>nginx.ingress.kubernetes.io/canary-by-header-value</a></td> <td>string</td> </tr> <tr> <td><a href=#canary>nginx.ingress.kubernetes.io/canary-by-header-pattern</a></td> <td>string</td> </tr> <tr> <td><a href=#canary>nginx.ingress.kubernetes.io/canary-by-cookie</a></td> <td>string</td> </tr> <tr> <td><a href=#canary>nginx.ingress.kubernetes.io/canary-weight</a></td> <td>number</td> </tr> <tr> <td><a href=#canary>nginx.ingress.kubernetes.io/canary-weight-total</a></td> <td>number</td> </tr> <tr> <td><a href=#client-body-buffer-size>nginx.ingress.kubernetes.io/client-body-buffer-size</a></td> <td>string</td> </tr> <tr> <td><a href=#configuration-snippet>nginx.ingress.kubernetes.io/configuration-snippet</a></td> <td>string</td> </tr> <tr> <td><a href=#custom-http-errors>nginx.ingress.kubernetes.io/custom-http-errors</a></td> <td>[]int</td> </tr> <tr> <td><a href=#custom-headers>nginx.ingress.kubernetes.io/custom-headers</a></td> <td>string</td> </tr> <tr> <td><a href=#default-backend>nginx.ingress.kubernetes.io/default-backend</a></td> <td>string</td> </tr> <tr> <td><a href=#enable-cors>nginx.ingress.kubernetes.io/enable-cors</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#enable-cors>nginx.ingress.kubernetes.io/cors-allow-origin</a></td> <td>string</td> </tr> <tr> <td><a href=#enable-cors>nginx.ingress.kubernetes.io/cors-allow-methods</a></td> <td>string</td> </tr> <tr> <td><a href=#enable-cors>nginx.ingress.kubernetes.io/cors-allow-headers</a></td> <td>string</td> </tr> <tr> <td><a href=#enable-cors>nginx.ingress.kubernetes.io/cors-expose-headers</a></td> <td>string</td> </tr> <tr> <td><a href=#enable-cors>nginx.ingress.kubernetes.io/cors-allow-credentials</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#enable-cors>nginx.ingress.kubernetes.io/cors-max-age</a></td> <td>number</td> </tr> <tr> <td><a href=#server-side-https-enforcement-through-redirect>nginx.ingress.kubernetes.io/force-ssl-redirect</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#redirect-fromto-www>nginx.ingress.kubernetes.io/from-to-www-redirect</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#http2-push-preload>nginx.ingress.kubernetes.io/http2-push-preload</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#rate-limiting>nginx.ingress.kubernetes.io/limit-connections</a></td> <td>number</td> </tr> <tr> <td><a href=#rate-limiting>nginx.ingress.kubernetes.io/limit-rps</a></td> <td>number</td> </tr> <tr> <td><a href=#permanent-redirect>nginx.ingress.kubernetes.io/permanent-redirect</a></td> <td>string</td> </tr> <tr> <td><a href=#permanent-redirect-code>nginx.ingress.kubernetes.io/permanent-redirect-code</a></td> <td>number</td> </tr> <tr> <td><a href=#temporal-redirect>nginx.ingress.kubernetes.io/temporal-redirect</a></td> <td>string</td> </tr> <tr> <td><a href=#temporal-redirect-code>nginx.ingress.kubernetes.io/temporal-redirect-code</a></td> <td>number</td> </tr> <tr> <td><a href=#server-side-https-enforcement-through-redirect>nginx.ingress.kubernetes.io/preserve-trailing-slash</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#custom-max-body-size>nginx.ingress.kubernetes.io/proxy-body-size</a></td> <td>string</td> </tr> <tr> <td><a href=#proxy-cookie-domain>nginx.ingress.kubernetes.io/proxy-cookie-domain</a></td> <td>string</td> </tr> <tr> <td><a href=#proxy-cookie-path>nginx.ingress.kubernetes.io/proxy-cookie-path</a></td> <td>string</td> </tr> <tr> <td><a href=#custom-timeouts>nginx.ingress.kubernetes.io/proxy-connect-timeout</a></td> <td>number</td> </tr> <tr> <td><a href=#custom-timeouts>nginx.ingress.kubernetes.io/proxy-send-timeout</a></td> <td>number</td> </tr> <tr> <td><a href=#custom-timeouts>nginx.ingress.kubernetes.io/proxy-read-timeout</a></td> <td>number</td> </tr> <tr> <td><a href=#custom-timeouts>nginx.ingress.kubernetes.io/proxy-next-upstream</a></td> <td>string</td> </tr> <tr> <td><a href=#custom-timeouts>nginx.ingress.kubernetes.io/proxy-next-upstream-timeout</a></td> <td>number</td> </tr> <tr> <td><a href=#custom-timeouts>nginx.ingress.kubernetes.io/proxy-next-upstream-tries</a></td> <td>number</td> </tr> <tr> <td><a href=#custom-timeouts>nginx.ingress.kubernetes.io/proxy-request-buffering</a></td> <td>string</td> </tr> <tr> <td><a href=#proxy-redirect>nginx.ingress.kubernetes.io/proxy-redirect-from</a></td> <td>string</td> </tr> <tr> <td><a href=#proxy-redirect>nginx.ingress.kubernetes.io/proxy-redirect-to</a></td> <td>string</td> </tr> <tr> <td><a href=#proxy-http-version>nginx.ingress.kubernetes.io/proxy-http-version</a></td> <td>"1.0" or "1.1"</td> </tr> <tr> <td><a href=#backend-certificate-authentication>nginx.ingress.kubernetes.io/proxy-ssl-secret</a></td> <td>string</td> </tr> <tr> <td><a href=#backend-certificate-authentication>nginx.ingress.kubernetes.io/proxy-ssl-ciphers</a></td> <td>string</td> </tr> <tr> <td><a href=#backend-certificate-authentication>nginx.ingress.kubernetes.io/proxy-ssl-name</a></td> <td>string</td> </tr> <tr> <td><a href=#backend-certificate-authentication>nginx.ingress.kubernetes.io/proxy-ssl-protocols</a></td> <td>string</td> </tr> <tr> <td><a href=#backend-certificate-authentication>nginx.ingress.kubernetes.io/proxy-ssl-verify</a></td> <td>string</td> </tr> <tr> <td><a href=#backend-certificate-authentication>nginx.ingress.kubernetes.io/proxy-ssl-verify-depth</a></td> <td>number</td> </tr> <tr> <td><a href=#backend-certificate-authentication>nginx.ingress.kubernetes.io/proxy-ssl-server-name</a></td> <td>string</td> </tr> <tr> <td><a href=#enable-rewrite-log>nginx.ingress.kubernetes.io/enable-rewrite-log</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#rewrite>nginx.ingress.kubernetes.io/rewrite-target</a></td> <td>URI</td> </tr> <tr> <td><a href=#satisfy>nginx.ingress.kubernetes.io/satisfy</a></td> <td>string</td> </tr> <tr> <td><a href=#server-alias>nginx.ingress.kubernetes.io/server-alias</a></td> <td>string</td> </tr> <tr> <td><a href=#server-snippet>nginx.ingress.kubernetes.io/server-snippet</a></td> <td>string</td> </tr> <tr> <td><a href=#service-upstream>nginx.ingress.kubernetes.io/service-upstream</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-change-on-failure</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-conditional-samesite-none</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-domain</a></td> <td>string</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-expires</a></td> <td>string</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-max-age</a></td> <td>string</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-name</a></td> <td>string</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-path</a></td> <td>string</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-samesite</a></td> <td>string</td> </tr> <tr> <td><a href=#cookie-affinity>nginx.ingress.kubernetes.io/session-cookie-secure</a></td> <td>string</td> </tr> <tr> <td><a href=#server-side-https-enforcement-through-redirect>nginx.ingress.kubernetes.io/ssl-redirect</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#ssl-passthrough>nginx.ingress.kubernetes.io/ssl-passthrough</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#stream-snippet>nginx.ingress.kubernetes.io/stream-snippet</a></td> <td>string</td> </tr> <tr> <td><a href=#custom-nginx-upstream-hashing>nginx.ingress.kubernetes.io/upstream-hash-by</a></td> <td>string</td> </tr> <tr> <td><a href=#x-forwarded-prefix-header>nginx.ingress.kubernetes.io/x-forwarded-prefix</a></td> <td>string</td> </tr> <tr> <td><a href=#custom-nginx-load-balancing>nginx.ingress.kubernetes.io/load-balance</a></td> <td>string</td> </tr> <tr> <td><a href=#custom-nginx-upstream-vhost>nginx.ingress.kubernetes.io/upstream-vhost</a></td> <td>string</td> </tr> <tr> <td><a href=#denylist-source-range>nginx.ingress.kubernetes.io/denylist-source-range</a></td> <td>CIDR</td> </tr> <tr> <td><a href=#whitelist-source-range>nginx.ingress.kubernetes.io/whitelist-source-range</a></td> <td>CIDR</td> </tr> <tr> <td><a href=#proxy-buffering>nginx.ingress.kubernetes.io/proxy-buffering</a></td> <td>string</td> </tr> <tr> <td><a href=#proxy-buffers-number>nginx.ingress.kubernetes.io/proxy-buffers-number</a></td> <td>number</td> </tr> <tr> <td><a href=#proxy-buffer-size>nginx.ingress.kubernetes.io/proxy-buffer-size</a></td> <td>string</td> </tr> <tr> <td><a href=#proxy-busy-buffers-size>nginx.ingress.kubernetes.io/proxy-busy-buffers-size</a></td> <td>string</td> </tr> <tr> <td><a href=#proxy-max-temp-file-size>nginx.ingress.kubernetes.io/proxy-max-temp-file-size</a></td> <td>string</td> </tr> <tr> <td><a href=#ssl-ciphers>nginx.ingress.kubernetes.io/ssl-ciphers</a></td> <td>string</td> </tr> <tr> <td><a href=#ssl-ciphers>nginx.ingress.kubernetes.io/ssl-prefer-server-ciphers</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#connection-proxy-header>nginx.ingress.kubernetes.io/connection-proxy-header</a></td> <td>string</td> </tr> <tr> <td><a href=#enable-access-log>nginx.ingress.kubernetes.io/enable-access-log</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#enable-opentelemetry>nginx.ingress.kubernetes.io/enable-opentelemetry</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#opentelemetry-trust-incoming-spans>nginx.ingress.kubernetes.io/opentelemetry-trust-incoming-span</a></td> <td>"true" or "false"</td> </tr> <tr> <td><a href=#use-regex>nginx.ingress.kubernetes.io/use-regex</a></td> <td>bool</td> </tr> <tr> <td><a href=#modsecurity>nginx.ingress.kubernetes.io/enable-modsecurity</a></td> <td>bool</td> </tr> <tr> <td><a href=#modsecurity>nginx.ingress.kubernetes.io/enable-owasp-core-rules</a></td> <td>bool</td> </tr> <tr> <td><a href=#modsecurity>nginx.ingress.kubernetes.io/modsecurity-transaction-id</a></td> <td>string</td> </tr> <tr> <td><a href=#modsecurity>nginx.ingress.kubernetes.io/modsecurity-snippet</a></td> <td>string</td> </tr> <tr> <td><a href=#mirror>nginx.ingress.kubernetes.io/mirror-request-body</a></td> <td>string</td> </tr> <tr> <td><a href=#mirror>nginx.ingress.kubernetes.io/mirror-target</a></td> <td>string</td> </tr> <tr> <td><a href=#mirror>nginx.ingress.kubernetes.io/mirror-host</a></td> <td>string</td> </tr> </tbody> </table> <h3 id=canary>Canary<a class=headerlink href=#canary title="Permanent link"></a></h3> <p>In some cases, you may want to "canary" a new set of changes by sending a small number of requests to a different service than the production service. The canary annotation enables the Ingress spec to act as an alternative service for requests to route to depending on the rules applied. The following annotations to configure canary can be enabled after <code>nginx.ingress.kubernetes.io/canary: "true"</code> is set:</p> <ul> <li> <p><code>nginx.ingress.kubernetes.io/canary-by-header</code>: The header to use for notifying the Ingress to route the request to the service specified in the Canary Ingress. When the request header is set to <code>always</code>, it will be routed to the canary. When the header is set to <code>never</code>, it will never be routed to the canary. For any other value, the header will be ignored and the request compared against the other canary rules by precedence.</p> </li> <li> <p><code>nginx.ingress.kubernetes.io/canary-by-header-value</code>: The header value to match for notifying the Ingress to route the request to the service specified in the Canary Ingress. When the request header is set to this value, it will be routed to the canary. For any other header value, the header will be ignored and the request compared against the other canary rules by precedence. This annotation has to be used together with <code>nginx.ingress.kubernetes.io/canary-by-header</code>. The annotation is an extension of the <code>nginx.ingress.kubernetes.io/canary-by-header</code> to allow customizing the header value instead of using hardcoded values. It doesn't have any effect if the <code>nginx.ingress.kubernetes.io/canary-by-header</code> annotation is not defined.</p> </li> <li> <p><code>nginx.ingress.kubernetes.io/canary-by-header-pattern</code>: This works the same way as <code>canary-by-header-value</code> except it does PCRE Regex matching. Note that when <code>canary-by-header-value</code> is set this annotation will be ignored. When the given Regex causes error during request processing, the request will be considered as not matching.</p> </li> <li> <p><code>nginx.ingress.kubernetes.io/canary-by-cookie</code>: The cookie to use for notifying the Ingress to route the request to the service specified in the Canary Ingress. When the cookie value is set to <code>always</code>, it will be routed to the canary. When the cookie is set to <code>never</code>, it will never be routed to the canary. For any other value, the cookie will be ignored and the request compared against the other canary rules by precedence.</p> </li> <li> <p><code>nginx.ingress.kubernetes.io/canary-weight</code>: The integer based (0 - <weight-total>) percent of random requests that should be routed to the service specified in the canary Ingress. A weight of 0 implies that no requests will be sent to the service in the Canary ingress by this canary rule. A weight of <code>&lt;weight-total&gt;</code> means implies all requests will be sent to the alternative service specified in the Ingress. <code>&lt;weight-total&gt;</code> defaults to 100, and can be increased via <code>nginx.ingress.kubernetes.io/canary-weight-total</code>.</p> </li> <li> <p><code>nginx.ingress.kubernetes.io/canary-weight-total</code>: The total weight of traffic. If unspecified, it defaults to 100.</p> </li> </ul> <p>Canary rules are evaluated in order of precedence. Precedence is as follows: <code>canary-by-header -&gt; canary-by-cookie -&gt; canary-weight</code></p> <p><strong>Note</strong> that when you mark an ingress as canary, then all the other non-canary annotations will be ignored (inherited from the corresponding main ingress) except <code>nginx.ingress.kubernetes.io/load-balance</code>, <code>nginx.ingress.kubernetes.io/upstream-hash-by</code>, and <a href=#session-affinity>annotations related to session affinity</a>. If you want to restore the original behavior of canaries when session affinity was ignored, set <code>nginx.ingress.kubernetes.io/affinity-canary-behavior</code> annotation with value <code>legacy</code> on the canary ingress definition.</p> <p><strong>Known Limitations</strong></p> <p>Currently a maximum of one canary ingress can be applied per Ingress rule.</p> <h3 id=rewrite>Rewrite<a class=headerlink href=#rewrite title="Permanent link"></a></h3> <p>In some scenarios the exposed URL in the backend service differs from the specified path in the Ingress rule. Without a rewrite any request will return 404. Set the annotation <code>nginx.ingress.kubernetes.io/rewrite-target</code> to the path expected by the service.</p> <p>If the Application Root is exposed in a different path and needs to be redirected, set the annotation <code>nginx.ingress.kubernetes.io/app-root</code> to redirect requests for <code>/</code>.</p> <div class="admonition example"> <p class=admonition-title>Example</p> <p>Please check the <a href=../../../examples/rewrite/ >rewrite</a> example.</p> </div> <h3 id=session-affinity>Session Affinity<a class=headerlink href=#session-affinity title="Permanent link"></a></h3> <p>The annotation <code>nginx.ingress.kubernetes.io/affinity</code> enables and sets the affinity type in all Upstreams of an Ingress. This way, a request will always be directed to the same upstream server. The only affinity type available for NGINX is <code>cookie</code>.</p> <p>The annotation <code>nginx.ingress.kubernetes.io/affinity-mode</code> defines the stickiness of a session. Setting this to <code>balanced</code> (default) will redistribute some sessions if a deployment gets scaled up, therefore rebalancing the load on the servers. Setting this to <code>persistent</code> will not rebalance sessions to new servers, therefore providing maximum stickiness.</p> <p>The annotation <code>nginx.ingress.kubernetes.io/affinity-canary-behavior</code> defines the behavior of canaries when session affinity is enabled. Setting this to <code>sticky</code> (default) will ensure that users that were served by canaries, will continue to be served by canaries. Setting this to <code>legacy</code> will restore original canary behavior, when session affinity was ignored.</p> <div class="admonition attention"> <p class=admonition-title>Attention</p> <p>If more than one Ingress is defined for a host and at least one Ingress uses <code>nginx.ingress.kubernetes.io/affinity: cookie</code>, then only paths on the Ingress using <code>nginx.ingress.kubernetes.io/affinity</code> will use session cookie affinity. All paths defined on other Ingresses for the host will be load balanced through the random selection of a backend server.</p> </div> <div class="admonition example"> <p class=admonition-title>Example</p> <p>Please check the <a href=../../../examples/affinity/cookie/ >affinity</a> example.</p> </div> <h4 id=cookie-affinity>Cookie affinity<a class=headerlink href=#cookie-affinity title="Permanent link"></a></h4> <p>If you use the <code>cookie</code> affinity type you can also specify the name of the cookie that will be used to route the requests with the annotation <code>nginx.ingress.kubernetes.io/session-cookie-name</code>. The default is to create a cookie named 'INGRESSCOOKIE'.</p> <p>The NGINX annotation <code>nginx.ingress.kubernetes.io/session-cookie-path</code> defines the path that will be set on the cookie. This is optional unless the annotation <code>nginx.ingress.kubernetes.io/use-regex</code> is set to true; Session cookie paths do not support regex.</p> <p>Use <code>nginx.ingress.kubernetes.io/session-cookie-domain</code> to set the <code>Domain</code> attribute of the sticky cookie.</p> <p>Use <code>nginx.ingress.kubernetes.io/session-cookie-samesite</code> to apply a <code>SameSite</code> attribute to the sticky cookie. Browser accepted values are <code>None</code>, <code>Lax</code>, and <code>Strict</code>. Some browsers reject cookies with <code>SameSite=None</code>, including those created before the <code>SameSite=None</code> specification (e.g. Chrome 5X). Other browsers mistakenly treat <code>SameSite=None</code> cookies as <code>SameSite=Strict</code> (e.g. Safari running on OSX 14). To omit <code>SameSite=None</code> from browsers with these incompatibilities, add the annotation <code>nginx.ingress.kubernetes.io/session-cookie-conditional-samesite-none: "true"</code>.</p> <p>Use <code>nginx.ingress.kubernetes.io/session-cookie-expires</code> to control the cookie expires, its value is a number of seconds until the cookie expires.</p> <p>Use <code>nginx.ingress.kubernetes.io/session-cookie-path</code> to control the cookie path when use-regex is set to true.</p> <p>Use <code>nginx.ingress.kubernetes.io/session-cookie-change-on-failure</code> to control the cookie change after request failure.</p> <h3 id=authentication>Authentication<a class=headerlink href=#authentication title="Permanent link"></a></h3> <p>It is possible to add authentication by adding additional annotations in the Ingress rule. The source of the authentication is a secret that contains usernames and passwords.</p> <p>The annotations are: <div class=highlight><pre><span></span><code>nginx.ingress.kubernetes.io/auth-type: [basic|digest]
</code></pre></div></p> <p>Indicates the <a href=https://tools.ietf.org/html/rfc2617>HTTP Authentication Type: Basic or Digest Access Authentication</a>.</p> <div class=highlight><pre><span></span><code>nginx.ingress.kubernetes.io/auth-secret: secretName
</code></pre></div> <p>The name of the Secret that contains the usernames and passwords which are granted access to the <code>path</code>s defined in the Ingress rules. This annotation also accepts the alternative form "namespace/secretName", in which case the Secret lookup is performed in the referenced namespace instead of the Ingress namespace.</p> <div class=highlight><pre><span></span><code>nginx.ingress.kubernetes.io/auth-secret-type: [auth-file|auth-map]
</code></pre></div> <p>The <code>auth-secret</code> can have two forms:</p> <ul> <li><code>auth-file</code> - default, an htpasswd file in the key <code>auth</code> within the secret</li> <li><code>auth-map</code> - the keys of the secret are the usernames, and the values are the hashed passwords</li> </ul> <div class=highlight><pre><span></span><code>nginx.ingress.kubernetes.io/auth-realm: &quot;realm string&quot;
</code></pre></div> <div class="admonition example"> <p class=admonition-title>Example</p> <p>Please check the <a href=../../../examples/auth/basic/ >auth</a> example.</p> </div> <h3 id=custom-nginx-upstream-hashing>Custom NGINX upstream hashing<a class=headerlink href=#custom-nginx-upstream-hashing title="Permanent link"></a></h3> <p>NGINX supports load balancing by client-server mapping based on <a href=https://nginx.org/en/docs/http/ngx_http_upstream_module.html#hash>consistent hashing</a> for a given key. The key can contain text, variables or any combination thereof. This feature allows for request stickiness other than client IP or cookies. The <a href=https://www.last.fm/user/RJ/journal/2007/04/10/rz_libketama_-_a_consistent_hashing_algo_for_memcache_clients>ketama</a> consistent hashing method will be used which ensures only a few keys would be remapped to different servers on upstream group changes.</p> <p>There is a special mode of upstream hashing called subset. In this mode, upstream servers are grouped into subsets, and stickiness works by mapping keys to a subset instead of individual upstream servers. Specific server is chosen uniformly at random from the selected sticky subset. It provides a balance between stickiness and load distribution.</p> <p>To enable consistent hashing for a backend:</p> <p><code>nginx.ingress.kubernetes.io/upstream-hash-by</code>: the nginx variable, text value or any combination thereof to use for consistent hashing. For example: <code>nginx.ingress.kubernetes.io/upstream-hash-by: "$request_uri"</code> or <code>nginx.ingress.kubernetes.io/upstream-hash-by: "$request_uri$host"</code> or <code>nginx.ingress.kubernetes.io/upstream-hash-by: "${request_uri}-text-value"</code> to consistently hash upstream requests by the current request URI.</p> <p>"subset" hashing can be enabled setting <code>nginx.ingress.kubernetes.io/upstream-hash-by-subset</code>: "true". This maps requests to subset of nodes instead of a single one. <code>nginx.ingress.kubernetes.io/upstream-hash-by-subset-size</code> determines the size of each subset (default 3).</p> <p>Please check the <a href=../../../examples/chashsubset/deployment.yaml>chashsubset</a> example.</p> <h3 id=custom-nginx-load-balancing>Custom NGINX load balancing<a class=headerlink href=#custom-nginx-load-balancing title="Permanent link"></a></h3> <p>This is similar to <a href=../configmap/#load-balance><code>load-balance</code> in ConfigMap</a>, but configures load balancing algorithm per ingress.</p> <blockquote> <p>Note that <code>nginx.ingress.kubernetes.io/upstream-hash-by</code> takes preference over this. If this and <code>nginx.ingress.kubernetes.io/upstream-hash-by</code> are not set then we fallback to using globally configured load balancing algorithm.</p> </blockquote> <h3 id=custom-nginx-upstream-vhost>Custom NGINX upstream vhost<a class=headerlink href=#custom-nginx-upstream-vhost title="Permanent link"></a></h3> <p>This configuration setting allows you to control the value for host in the following statement: <code>proxy_set_header Host $host</code>, which forms part of the location block. This is useful if you need to call the upstream server by something other than <code>$host</code>.</p> <h3 id=client-certificate-authentication>Client Certificate Authentication<a class=headerlink href=#client-certificate-authentication title="Permanent link"></a></h3> <p>It is possible to enable Client Certificate Authentication using additional annotations in Ingress Rule.</p> <p>Client Certificate Authentication is applied per host and it is not possible to specify rules that differ for individual paths.</p> <p>To enable, add the annotation <code>nginx.ingress.kubernetes.io/auth-tls-secret: namespace/secretName</code>. This secret must have a file named <code>ca.crt</code> containing the full Certificate Authority chain <code>ca.crt</code> that is enabled to authenticate against this Ingress.</p> <p>You can further customize client certificate authentication and behavior with these annotations:</p> <ul> <li><code>nginx.ingress.kubernetes.io/auth-tls-verify-depth</code>: The validation depth between the provided client certificate and the Certification Authority chain. (default: 1)</li> <li><code>nginx.ingress.kubernetes.io/auth-tls-verify-client</code>: Enables verification of client certificates. Possible values are:<ul> <li><code>on</code>: Request a client certificate that must be signed by a certificate that is included in the secret key <code>ca.crt</code> of the secret specified by <code>nginx.ingress.kubernetes.io/auth-tls-secret: namespace/secretName</code>. Failed certificate verification will result in a status code 400 (Bad Request) (default)</li> <li><code>off</code>: Don't request client certificates and don't do client certificate verification.</li> <li><code>optional</code>: Do optional client certificate validation against the CAs from <code>auth-tls-secret</code>. The request fails with status code 400 (Bad Request) when a certificate is provided that is not signed by the CA. When no or an otherwise invalid certificate is provided, the request does not fail, but instead the verification result is sent to the upstream service.</li> <li><code>optional_no_ca</code>: Do optional client certificate validation, but do not fail the request when the client certificate is not signed by the CAs from <code>auth-tls-secret</code>. Certificate verification result is sent to the upstream service.</li> </ul> </li> <li><code>nginx.ingress.kubernetes.io/auth-tls-error-page</code>: The URL/Page that user should be redirected in case of a Certificate Authentication Error</li> <li><code>nginx.ingress.kubernetes.io/auth-tls-pass-certificate-to-upstream</code>: Indicates if the received certificates should be passed or not to the upstream server in the header <code>ssl-client-cert</code>. Possible values are "true" or "false" (default).</li> <li><code>nginx.ingress.kubernetes.io/auth-tls-match-cn</code>: Adds a sanity check for the CN of the client certificate that is sent over using a string / regex starting with "CN=", example: <code>"CN=myvalidclient"</code>. If the certificate CN sent during mTLS does not match your string / regex it will fail with status code 403. Another way of using this is by adding multiple options in your regex, example: <code>"CN=(option1|option2|myvalidclient)"</code>. In this case, as long as one of the options in the brackets matches the certificate CN then you will receive a 200 status code. </li> </ul> <p>The following headers are sent to the upstream service according to the <code>auth-tls-*</code> annotations:</p> <ul> <li><code>ssl-client-issuer-dn</code>: The issuer information of the client certificate. Example: "CN=My CA"</li> <li><code>ssl-client-subject-dn</code>: The subject information of the client certificate. Example: "CN=My Client"</li> <li><code>ssl-client-verify</code>: The result of the client verification. Possible values: "SUCCESS", "FAILED: <description, why the verification failed>"</li> <li><code>ssl-client-cert</code>: The full client certificate in PEM format. Will only be sent when <code>nginx.ingress.kubernetes.io/auth-tls-pass-certificate-to-upstream</code> is set to "true". Example: <code>-----BEGIN%20CERTIFICATE-----%0A...---END%20CERTIFICATE-----%0A</code></li> </ul> <div class="admonition example"> <p class=admonition-title>Example</p> <p>Please check the <a href=../../../examples/auth/client-certs/ >client-certs</a> example.</p> </div> <div class="admonition attention"> <p class=admonition-title>Attention</p> <p>TLS with Client Authentication is <strong>not</strong> possible in Cloudflare and might result in unexpected behavior.</p> <p>Cloudflare only allows Authenticated Origin Pulls and is required to use their own certificate: <a href=https://blog.cloudflare.com/protecting-the-origin-with-tls-authenticated-origin-pulls/ >https://blog.cloudflare.com/protecting-the-origin-with-tls-authenticated-origin-pulls/</a></p> <p>Only Authenticated Origin Pulls are allowed and can be configured by following their tutorial: <a href=https://web.archive.org/web/20200907143649/https://support.cloudflare.com/hc/en-us/articles/204899617-Setting-up-NGINX-to-use-TLS-Authenticated-Origin-Pulls#section5>https://support.cloudflare.com/hc/en-us/articles/204494148-Setting-up-NGINX-to-use-TLS-Authenticated-Origin-Pulls</a></p> </div> <h3 id=backend-certificate-authentication>Backend Certificate Authentication<a class=headerlink href=#backend-certificate-authentication title="Permanent link"></a></h3> <p>It is possible to authenticate to a proxied HTTPS backend with certificate using additional annotations in Ingress Rule.</p> <ul> <li><code>nginx.ingress.kubernetes.io/proxy-ssl-secret: secretName</code>: Specifies a Secret with the certificate <code>tls.crt</code>, key <code>tls.key</code> in PEM format used for authentication to a proxied HTTPS server. It should also contain trusted CA certificates <code>ca.crt</code> in PEM format used to verify the certificate of the proxied HTTPS server. This annotation expects the Secret name in the form "namespace/secretName".</li> <li><code>nginx.ingress.kubernetes.io/proxy-ssl-verify</code>: Enables or disables verification of the proxied HTTPS server certificate. (default: off)</li> <li><code>nginx.ingress.kubernetes.io/proxy-ssl-verify-depth</code>: Sets the verification depth in the proxied HTTPS server certificates chain. (default: 1)</li> <li><code>nginx.ingress.kubernetes.io/proxy-ssl-ciphers</code>: Specifies the enabled <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_ciphers>ciphers</a> for requests to a proxied HTTPS server. The ciphers are specified in the format understood by the OpenSSL library.</li> <li><code>nginx.ingress.kubernetes.io/proxy-ssl-name</code>: Allows to set <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_name>proxy_ssl_name</a>. This allows overriding the server name used to verify the certificate of the proxied HTTPS server. This value is also passed through SNI when a connection is established to the proxied HTTPS server.</li> <li><code>nginx.ingress.kubernetes.io/proxy-ssl-protocols</code>: Enables the specified <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_protocols>protocols</a> for requests to a proxied HTTPS server.</li> <li><code>nginx.ingress.kubernetes.io/proxy-ssl-server-name</code>: Enables passing of the server name through TLS Server Name Indication extension (SNI, RFC 6066) when establishing a connection with the proxied HTTPS server.</li> </ul> <h3 id=configuration-snippet>Configuration snippet<a class=headerlink href=#configuration-snippet title="Permanent link"></a></h3> <p>Using this annotation you can add additional configuration to the NGINX location. For example:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/configuration-snippet</span><span class=p>:</span><span class=w> </span><span class="p p-Indicator">|</span>
<span class=w> </span><span class=no>more_set_headers &quot;Request-Id: $req_id&quot;;</span>
</code></pre></div> <p>Be aware this can be dangerous in multi-tenant clusters, as it can lead to people with otherwise limited permissions being able to retrieve all secrets on the cluster. The recommended mitigation for this threat is to disable this feature, so it may not work for you. See CVE-2021-25742 and the <a href=https://github.com/kubernetes/ingress-nginx/issues/7837>related issue on github</a> for more information.</p> <h3 id=custom-http-errors>Custom HTTP Errors<a class=headerlink href=#custom-http-errors title="Permanent link"></a></h3> <p>Like the <a href=../configmap/#custom-http-errors><code>custom-http-errors</code></a> value in the ConfigMap, this annotation will set NGINX <code>proxy-intercept-errors</code>, but only for the NGINX location associated with this ingress. If a <a href=#default-backend>default backend annotation</a> is specified on the ingress, the errors will be routed to that annotation's default backend service (instead of the global default backend). Different ingresses can specify different sets of error codes. Even if multiple ingress objects share the same hostname, this annotation can be used to intercept different error codes for each ingress (for example, different error codes to be intercepted for different paths on the same hostname, if each path is on a different ingress). If <code>custom-http-errors</code> is also specified globally, the error values specified in this annotation will override the global value for the given ingress' hostname and path.</p> <p>Example usage: <div class=highlight><pre><span></span><code>nginx.ingress.kubernetes.io/custom-http-errors: &quot;404,415&quot;
</code></pre></div></p> <h3 id=custom-headers>Custom Headers<a class=headerlink href=#custom-headers title="Permanent link"></a></h3> <p>This annotation is of the form <code>nginx.ingress.kubernetes.io/custom-headers: &lt;namespace&gt;/&lt;custom headers configmap&gt;</code> to specify a namespace and configmap name that contains custom headers. This annotation uses <code>more_set_headers</code> nginx directive.</p> <p>Example annotation for following example configmap:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/custom-headers</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">default/custom-headers-configmap</span>
</code></pre></div> <p>Example configmap: <div class=highlight><pre><span></span><code><span class=nt>apiVersion</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">v1</span>
<span class=nt>data</span><span class=p>:</span>
<span class=w> </span><span class=nt>Content-Type</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">application/json</span>
<span class=nt>kind</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">ConfigMap</span>
<span class=nt>metadata</span><span class=p>:</span>
<span class=w> </span><span class=nt>name</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">custom-headers-configmap</span>
<span class=w> </span><span class=nt>namespace</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">default</span>
</code></pre></div></p> <div class="admonition attention"> <p class=admonition-title>Attention</p> </div> <p>First define the allowed response headers in <a href=https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/configmap.md#global-allowed-response-headers>global-allowed-response-headers</a>.</p> <h3 id=default-backend>Default Backend<a class=headerlink href=#default-backend title="Permanent link"></a></h3> <p>This annotation is of the form <code>nginx.ingress.kubernetes.io/default-backend: &lt;svc name&gt;</code> to specify a custom default backend. This <code>&lt;svc name&gt;</code> is a reference to a service inside of the same namespace in which you are applying this annotation. This annotation overrides the global default backend. In case the service has <a href=https://kubernetes.io/docs/concepts/services-networking/service/#multi-port-services>multiple ports</a>, the first one is the one which will receive the backend traffic. </p> <p>This service will be used to handle the response when the configured service in the Ingress rule does not have any active endpoints. It will also be used to handle the error responses if both this annotation and the <a href=#custom-http-errors>custom-http-errors annotation</a> are set.</p> <h3 id=enable-cors>Enable CORS<a class=headerlink href=#enable-cors title="Permanent link"></a></h3> <p>To enable Cross-Origin Resource Sharing (CORS) in an Ingress rule, add the annotation <code>nginx.ingress.kubernetes.io/enable-cors: "true"</code>. This will add a section in the server location enabling this functionality.</p> <p>CORS can be controlled with the following annotations:</p> <ul> <li> <p><code>nginx.ingress.kubernetes.io/cors-allow-methods</code>: Controls which methods are accepted.</p> <p>This is a multi-valued field, separated by ',' and accepts only letters (upper and lower case).</p> <ul> <li>Default: <code>GET, PUT, POST, DELETE, PATCH, OPTIONS</code></li> <li>Example: <code>nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"</code></li> </ul> </li> <li> <p><code>nginx.ingress.kubernetes.io/cors-allow-headers</code>: Controls which headers are accepted.</p> <p>This is a multi-valued field, separated by ',' and accepts letters, numbers, _ and -.</p> <ul> <li>Default: <code>DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization</code></li> <li>Example: <code>nginx.ingress.kubernetes.io/cors-allow-headers: "X-Forwarded-For, X-app123-XPTO"</code></li> </ul> </li> <li> <p><code>nginx.ingress.kubernetes.io/cors-expose-headers</code>: Controls which headers are exposed to response.</p> <p>This is a multi-valued field, separated by ',' and accepts letters, numbers, _, - and *.</p> <ul> <li>Default: <em>empty</em></li> <li>Example: <code>nginx.ingress.kubernetes.io/cors-expose-headers: "*, X-CustomResponseHeader"</code></li> </ul> </li> <li> <p><code>nginx.ingress.kubernetes.io/cors-allow-origin</code>: Controls what's the accepted Origin for CORS.</p> <p>This is a multi-valued field, separated by ','. It must follow this format: <code>protocol://origin-site.com</code> or <code>protocol://origin-site.com:port</code></p> <ul> <li>Default: <code>*</code></li> <li>Example: <code>nginx.ingress.kubernetes.io/cors-allow-origin: "https://origin-site.com:4443, http://origin-site.com, myprotocol://example.org:1199"</code></li> </ul> <p>It also supports single level wildcard subdomains and follows this format: <code>protocol://*.foo.bar</code>, <code>protocol://*.bar.foo:8080</code> or <code>protocol://*.abc.bar.foo:9000</code> - Example: <code>nginx.ingress.kubernetes.io/cors-allow-origin: "https://*.origin-site.com:4443, http://*.origin-site.com, myprotocol://example.org:1199"</code></p> </li> <li> <p><code>nginx.ingress.kubernetes.io/cors-allow-credentials</code>: Controls if credentials can be passed during CORS operations.</p> <ul> <li>Default: <code>true</code></li> <li>Example: <code>nginx.ingress.kubernetes.io/cors-allow-credentials: "false"</code></li> </ul> </li> <li> <p><code>nginx.ingress.kubernetes.io/cors-max-age</code>: Controls how long preflight requests can be cached.</p> <ul> <li>Default: <code>1728000</code></li> <li>Example: <code>nginx.ingress.kubernetes.io/cors-max-age: 600</code></li> </ul> </li> </ul> <div class="admonition note"> <p class=admonition-title>Note</p> <p>For more information please see <a href=https://enable-cors.org/server_nginx.html>https://enable-cors.org</a></p> </div> <h3 id=http2-push-preload>HTTP2 Push Preload.<a class=headerlink href=#http2-push-preload title="Permanent link"></a></h3> <p>Enables automatic conversion of preload links specified in the “Link” response header fields into push requests.</p> <div class="admonition example"> <p class=admonition-title>Example</p> <ul> <li><code>nginx.ingress.kubernetes.io/http2-push-preload: "true"</code></li> </ul> </div> <h3 id=server-alias>Server Alias<a class=headerlink href=#server-alias title="Permanent link"></a></h3> <p>Allows the definition of one or more aliases in the server definition of the NGINX configuration using the annotation <code>nginx.ingress.kubernetes.io/server-alias: "&lt;alias 1&gt;,&lt;alias 2&gt;"</code>. This will create a server with the same configuration, but adding new values to the <code>server_name</code> directive.</p> <div class="admonition note"> <p class=admonition-title>Note</p> <p>A server-alias name cannot conflict with the hostname of an existing server. If it does, the server-alias annotation will be ignored. If a server-alias is created and later a new server with the same hostname is created, the new server configuration will take place over the alias configuration.</p> </div> <p>For more information please see <a href=https://nginx.org/en/docs/http/ngx_http_core_module.html#server_name>the <code>server_name</code> documentation</a>.</p> <h3 id=server-snippet>Server snippet<a class=headerlink href=#server-snippet title="Permanent link"></a></h3> <p>Using the annotation <code>nginx.ingress.kubernetes.io/server-snippet</code> it is possible to add custom configuration in the server configuration block.</p> <div class=highlight><pre><span></span><code><span class=nt>apiVersion</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">networking.k8s.io/v1</span>
<span class=nt>kind</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">Ingress</span>
<span class=nt>metadata</span><span class=p>:</span>
<span class=w> </span><span class=nt>annotations</span><span class=p>:</span>
<span class=w> </span><span class=nt>nginx.ingress.kubernetes.io/server-snippet</span><span class=p>:</span><span class=w> </span><span class="p p-Indicator">|</span>
<span class=w> </span><span class=no>set $agentflag 0;</span>
<span class=w> </span><span class=no>if ($http_user_agent ~* &quot;(Mobile)&quot; ){</span>
<span class=w> </span><span class=no>set $agentflag 1;</span>
<span class=w> </span><span class=no>}</span>
<span class=w> </span><span class=no>if ( $agentflag = 1 ) {</span>
<span class=w> </span><span class=no>return 301 https://m.example.com;</span>
<span class=w> </span><span class=no>}</span>
</code></pre></div> <div class="admonition attention"> <p class=admonition-title>Attention</p> <p>This annotation can be used only once per host.</p> </div> <h3 id=client-body-buffer-size>Client Body Buffer Size<a class=headerlink href=#client-body-buffer-size title="Permanent link"></a></h3> <p>Sets buffer size for reading client request body per location. In case the request body is larger than the buffer, the whole body or only its part is written to a temporary file. By default, buffer size is equal to two memory pages. This is 8K on x86, other 32-bit platforms, and x86-64. It is usually 16K on other 64-bit platforms. This annotation is applied to each location provided in the ingress rule.</p> <div class="admonition note"> <p class=admonition-title>Note</p> <p>The annotation value must be given in a format understood by Nginx.</p> </div> <div class="admonition example"> <p class=admonition-title>Example</p> <ul> <li><code>nginx.ingress.kubernetes.io/client-body-buffer-size: "1000"</code> # 1000 bytes</li> <li><code>nginx.ingress.kubernetes.io/client-body-buffer-size: 1k</code> # 1 kilobyte</li> <li><code>nginx.ingress.kubernetes.io/client-body-buffer-size: 1K</code> # 1 kilobyte</li> <li><code>nginx.ingress.kubernetes.io/client-body-buffer-size: 1m</code> # 1 megabyte</li> <li><code>nginx.ingress.kubernetes.io/client-body-buffer-size: 1M</code> # 1 megabyte</li> </ul> </div> <p>For more information please see <a href=https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size>https://nginx.org</a></p> <h3 id=external-authentication>External Authentication<a class=headerlink href=#external-authentication title="Permanent link"></a></h3> <p>To use an existing service that provides authentication the Ingress rule can be annotated with <code>nginx.ingress.kubernetes.io/auth-url</code> to indicate the URL where the HTTP request should be sent.</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/auth-url</span><span class=p>:</span><span class=w> </span><span class=s>&quot;URL</span><span class=nv> </span><span class=s>to</span><span class=nv> </span><span class=s>the</span><span class=nv> </span><span class=s>authentication</span><span class=nv> </span><span class=s>service&quot;</span>
</code></pre></div> <p>Additionally it is possible to set:</p> <ul> <li><code>nginx.ingress.kubernetes.io/auth-keepalive</code>: <code>&lt;Connections&gt;</code> to specify the maximum number of keepalive connections to <code>auth-url</code>. Only takes effect when no variables are used in the host part of the URL. Defaults to <code>0</code> (keepalive disabled).</li> </ul> <blockquote> <p>Note: does not work with HTTP/2 listener because of a limitation in Lua <a href=https://github.com/openresty/lua-nginx-module#spdy-mode-not-fully-supported>subrequests</a>. <a href=../configmap/#use-http2>UseHTTP2</a> configuration should be disabled!</p> </blockquote> <ul> <li><code>nginx.ingress.kubernetes.io/auth-keepalive-share-vars</code>: Whether to share Nginx variables among the current request and the auth request. Example use case is to track requests: when set to "true" X-Request-ID HTTP header will be the same for the backend and the auth request. Defaults to "false".</li> <li><code>nginx.ingress.kubernetes.io/auth-keepalive-requests</code>: <code>&lt;Requests&gt;</code> to specify the maximum number of requests that can be served through one keepalive connection. Defaults to <code>1000</code> and only applied if <code>auth-keepalive</code> is set to higher than <code>0</code>.</li> <li><code>nginx.ingress.kubernetes.io/auth-keepalive-timeout</code>: <code>&lt;Timeout&gt;</code> to specify a duration in seconds which an idle keepalive connection to an upstream server will stay open. Defaults to <code>60</code> and only applied if <code>auth-keepalive</code> is set to higher than <code>0</code>.</li> <li><code>nginx.ingress.kubernetes.io/auth-method</code>: <code>&lt;Method&gt;</code> to specify the HTTP method to use.</li> <li><code>nginx.ingress.kubernetes.io/auth-signin</code>: <code>&lt;SignIn_URL&gt;</code> to specify the location of the error page.</li> <li><code>nginx.ingress.kubernetes.io/auth-signin-redirect-param</code>: <code>&lt;SignIn_URL&gt;</code> to specify the URL parameter in the error page which should contain the original URL for a failed signin request.</li> <li><code>nginx.ingress.kubernetes.io/auth-response-headers</code>: <code>&lt;Response_Header_1, ..., Response_Header_n&gt;</code> to specify headers to pass to backend once authentication request completes.</li> <li><code>nginx.ingress.kubernetes.io/auth-proxy-set-headers</code>: <code>&lt;ConfigMap&gt;</code> the name of a ConfigMap that specifies headers to pass to the authentication service</li> <li><code>nginx.ingress.kubernetes.io/auth-request-redirect</code>: <code>&lt;Request_Redirect_URL&gt;</code> to specify the X-Auth-Request-Redirect header value.</li> <li><code>nginx.ingress.kubernetes.io/auth-cache-key</code>: <code>&lt;Cache_Key&gt;</code> this enables caching for auth requests. specify a lookup key for auth responses. e.g. <code>$remote_user$http_authorization</code>. Each server and location has it's own keyspace. Hence a cached response is only valid on a per-server and per-location basis.</li> <li><code>nginx.ingress.kubernetes.io/auth-cache-duration</code>: <code>&lt;Cache_duration&gt;</code> to specify a caching time for auth responses based on their response codes, e.g. <code>200 202 30m</code>. See <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid>proxy_cache_valid</a> for details. You may specify multiple, comma-separated values: <code>200 202 10m, 401 5m</code>. defaults to <code>200 202 401 5m</code>.</li> <li><code>nginx.ingress.kubernetes.io/auth-always-set-cookie</code>: <code>&lt;Boolean_Flag&gt;</code> to set a cookie returned by auth request. By default, the cookie will be set only if an upstream reports with the code 200, 201, 204, 206, 301, 302, 303, 304, 307, or 308.</li> <li><code>nginx.ingress.kubernetes.io/auth-snippet</code>: <code>&lt;Auth_Snippet&gt;</code> to specify a custom snippet to use with external authentication, e.g.</li> </ul> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/auth-url</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">http://foo.com/external-auth</span>
<span class=nt>nginx.ingress.kubernetes.io/auth-snippet</span><span class=p>:</span><span class=w> </span><span class="p p-Indicator">|</span>
<span class=w> </span><span class=no>proxy_set_header Foo-Header 42;</span>
</code></pre></div> <blockquote> <p>Note: <code>nginx.ingress.kubernetes.io/auth-snippet</code> is an optional annotation. However, it may only be used in conjunction with <code>nginx.ingress.kubernetes.io/auth-url</code> and will be ignored if <code>nginx.ingress.kubernetes.io/auth-url</code> is not set</p> </blockquote> <div class="admonition example"> <p class=admonition-title>Example</p> <p>Please check the <a href=../../../examples/auth/external-auth/ >external-auth</a> example.</p> </div> <h4 id=global-external-authentication>Global External Authentication<a class=headerlink href=#global-external-authentication title="Permanent link"></a></h4> <p>By default the controller redirects all requests to an existing service that provides authentication if <code>global-auth-url</code> is set in the NGINX ConfigMap. If you want to disable this behavior for that ingress, you can use <code>enable-global-auth: "false"</code> in the NGINX ConfigMap. <code>nginx.ingress.kubernetes.io/enable-global-auth</code>: indicates if GlobalExternalAuth configuration should be applied or not to this Ingress rule. Default values is set to <code>"true"</code>.</p> <div class="admonition note"> <p class=admonition-title>Note</p> <p>For more information please see <a href=../configmap/#global-auth-url>global-auth-url</a>.</p> </div> <h3 id=rate-limiting>Rate Limiting<a class=headerlink href=#rate-limiting title="Permanent link"></a></h3> <p>These annotations define limits on connections and transmission rates. These can be used to mitigate <a href=https://www.nginx.com/blog/mitigating-ddos-attacks-with-nginx-and-nginx-plus>DDoS Attacks</a>.</p> <div class="admonition attention"> <p class=admonition-title>Attention</p> <p>Rate limits are applied per Ingress NGINX controller replica. If you're running multiple replicas or using a horizontal pod autoscaler (HPA), the effective rate limit will be multiplied by the number of replicas. When using HPA, the exact rate limit becomes dynamic as the number of replicas may change based on load.</p> </div> <ul> <li><code>nginx.ingress.kubernetes.io/limit-connections</code>: number of concurrent connections allowed from a single IP address per controller replica. A 503 error is returned when exceeding this limit.</li> <li><code>nginx.ingress.kubernetes.io/limit-rps</code>: number of requests accepted from a given IP each second per controller replica. The burst limit is set to this limit multiplied by the burst multiplier, the default multiplier is 5. When clients exceed this limit, <a href=https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#limit-req-status-code>limit-req-status-code</a> <strong><em>default:</em></strong> 503 is returned.</li> <li><code>nginx.ingress.kubernetes.io/limit-rpm</code>: number of requests accepted from a given IP each minute per controller replica. The burst limit is set to this limit multiplied by the burst multiplier, the default multiplier is 5. When clients exceed this limit, <a href=https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#limit-req-status-code>limit-req-status-code</a> <strong><em>default:</em></strong> 503 is returned.</li> <li><code>nginx.ingress.kubernetes.io/limit-burst-multiplier</code>: multiplier of the limit rate for burst size. The default burst multiplier is 5, this annotation override the default multiplier. When clients exceed this limit, <a href=https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#limit-req-status-code>limit-req-status-code</a> <strong><em>default:</em></strong> 503 is returned.</li> <li><code>nginx.ingress.kubernetes.io/limit-rate-after</code>: initial number of kilobytes after which the further transmission of a response to a given connection will be rate limited. This feature must be used with <a href=#proxy-buffering>proxy-buffering</a> enabled.</li> <li><code>nginx.ingress.kubernetes.io/limit-rate</code>: number of kilobytes per second allowed to send to a given connection. The zero value disables rate limiting. This feature must be used with <a href=#proxy-buffering>proxy-buffering</a> enabled.</li> <li><code>nginx.ingress.kubernetes.io/limit-whitelist</code>: client IP source ranges to be excluded from rate-limiting. The value is a comma separated list of CIDRs.</li> </ul> <p>If you specify multiple annotations in a single Ingress rule, limits are applied in the order <code>limit-connections</code>, <code>limit-rpm</code>, <code>limit-rps</code>.</p> <p>To configure settings globally for all Ingress rules, the <code>limit-rate-after</code> and <code>limit-rate</code> values may be set in the <a href=../configmap/#limit-rate>NGINX ConfigMap</a>. The value set in an Ingress annotation will override the global setting.</p> <p>The client IP address will be set based on the use of <a href=../configmap/#use-proxy-protocol>PROXY protocol</a> or from the <code>X-Forwarded-For</code> header value when <a href=../configmap/#use-forwarded-headers>use-forwarded-headers</a> is enabled.</p> <h3 id=permanent-redirect>Permanent Redirect<a class=headerlink href=#permanent-redirect title="Permanent link"></a></h3> <p>This annotation allows to return a permanent redirect (Return Code 301) instead of sending data to the upstream. For example <code>nginx.ingress.kubernetes.io/permanent-redirect: https://www.google.com</code> would redirect everything to Google.</p> <h3 id=permanent-redirect-code>Permanent Redirect Code<a class=headerlink href=#permanent-redirect-code title="Permanent link"></a></h3> <p>This annotation allows you to modify the status code used for permanent redirects. For example <code>nginx.ingress.kubernetes.io/permanent-redirect-code: '308'</code> would return your permanent-redirect with a 308.</p> <h3 id=temporal-redirect>Temporal Redirect<a class=headerlink href=#temporal-redirect title="Permanent link"></a></h3> <p>This annotation allows you to return a temporal redirect (Return Code 302) instead of sending data to the upstream. For example <code>nginx.ingress.kubernetes.io/temporal-redirect: https://www.google.com</code> would redirect everything to Google with a Return Code of 302 (Moved Temporarily)</p> <h3 id=temporal-redirect-code>Temporal Redirect Code<a class=headerlink href=#temporal-redirect-code title="Permanent link"></a></h3> <p>This annotation allows you to modify the status code used for temporal redirects. For example <code>nginx.ingress.kubernetes.io/temporal-redirect-code: '307'</code> would return your temporal-redirect with a 307.</p> <h3 id=ssl-passthrough>SSL Passthrough<a class=headerlink href=#ssl-passthrough title="Permanent link"></a></h3> <p>The annotation <code>nginx.ingress.kubernetes.io/ssl-passthrough</code> instructs the controller to send TLS connections directly to the backend instead of letting NGINX decrypt the communication. See also <a href=../../tls/#ssl-passthrough>TLS/HTTPS</a> in the User guide.</p> <div class="admonition note"> <p class=admonition-title>Note</p> <p>SSL Passthrough is <strong>disabled by default</strong> and requires starting the controller with the <a href=../../cli-arguments/ ><code>--enable-ssl-passthrough</code></a> flag.</p> </div> <div class="admonition attention"> <p class=admonition-title>Attention</p> <p>Because SSL Passthrough works on layer 4 of the OSI model (TCP) and not on the layer 7 (HTTP), using SSL Passthrough invalidates all the other annotations set on an Ingress object.</p> </div> <h3 id=service-upstream>Service Upstream<a class=headerlink href=#service-upstream title="Permanent link"></a></h3> <p>By default the Ingress-Nginx Controller uses a list of all endpoints (Pod IP/port) in the NGINX upstream configuration.</p> <p>The <code>nginx.ingress.kubernetes.io/service-upstream</code> annotation disables that behavior and instead uses a single upstream in NGINX, the service's Cluster IP and port.</p> <p>This can be desirable for things like zero-downtime deployments . See issue <a href=https://github.com/kubernetes/ingress-nginx/issues/257>#257</a>.</p> <h4 id=known-issues>Known Issues<a class=headerlink href=#known-issues title="Permanent link"></a></h4> <p>If the <code>service-upstream</code> annotation is specified the following things should be taken into consideration:</p> <ul> <li>Sticky Sessions will not work as only round-robin load balancing is supported.</li> <li>The <code>proxy_next_upstream</code> directive will not have any effect meaning on error the request will not be dispatched to another upstream.</li> </ul> <h3 id=server-side-https-enforcement-through-redirect>Server-side HTTPS enforcement through redirect<a class=headerlink href=#server-side-https-enforcement-through-redirect title="Permanent link"></a></h3> <p>By default the controller redirects (308) to HTTPS if TLS is enabled for that ingress. If you want to disable this behavior globally, you can use <code>ssl-redirect: "false"</code> in the NGINX <a href=../configmap/#ssl-redirect>ConfigMap</a>.</p> <p>To configure this feature for specific ingress resources, you can use the <code>nginx.ingress.kubernetes.io/ssl-redirect: "false"</code> annotation in the particular resource.</p> <p>When using SSL offloading outside of cluster (e.g. AWS ELB) it may be useful to enforce a redirect to HTTPS even when there is no TLS certificate available. This can be achieved by using the <code>nginx.ingress.kubernetes.io/force-ssl-redirect: "true"</code> annotation in the particular resource.</p> <p>To preserve the trailing slash in the URI with <code>ssl-redirect</code>, set <code>nginx.ingress.kubernetes.io/preserve-trailing-slash: "true"</code> annotation for that particular resource.</p> <h3 id=redirect-fromto-www>Redirect from/to www<a class=headerlink href=#redirect-fromto-www title="Permanent link"></a></h3> <p>In some scenarios, it is required to redirect from <code>www.domain.com</code> to <code>domain.com</code> or vice versa, which way the redirect is performed depends on the configured <code>host</code> value in the Ingress object.</p> <p>For example, if <code>.spec.rules.host</code> is configured with a value like <code>www.example.com</code>, then this annotation will redirect from <code>example.com</code> to <code>www.example.com</code>. If <code>.spec.rules.host</code> is configured with a value like <code>example.com</code>, so without a <code>www</code>, then this annotation will redirect from <code>www.example.com</code> to <code>example.com</code> instead.</p> <p>To enable this feature use the annotation <code>nginx.ingress.kubernetes.io/from-to-www-redirect: "true"</code></p> <div class="admonition attention"> <p class=admonition-title>Attention</p> <p>If at some point a new Ingress is created with a host equal to one of the options (like <code>domain.com</code>) the annotation will be omitted.</p> </div> <div class="admonition attention"> <p class=admonition-title>Attention</p> <p>For HTTPS to HTTPS redirects is mandatory the SSL Certificate defined in the Secret, located in the TLS section of Ingress, contains both FQDN in the common name of the certificate.</p> </div> <h3 id=denylist-source-range>Denylist source range<a class=headerlink href=#denylist-source-range title="Permanent link"></a></h3> <p>You can specify blocked client IP source ranges through the <code>nginx.ingress.kubernetes.io/denylist-source-range</code> annotation. The value is a comma separated list of <a href=https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing>CIDRs</a>, e.g. <code>10.0.0.0/24,172.10.0.1</code>.</p> <p>To configure this setting globally for all Ingress rules, the <code>denylist-source-range</code> value may be set in the <a href=../configmap/#denylist-source-range>NGINX ConfigMap</a>.</p> <div class="admonition note"> <p class=admonition-title>Note</p> <p>Adding an annotation to an Ingress rule overrides any global restriction.</p> </div> <h3 id=whitelist-source-range>Whitelist source range<a class=headerlink href=#whitelist-source-range title="Permanent link"></a></h3> <p>You can specify allowed client IP source ranges through the <code>nginx.ingress.kubernetes.io/whitelist-source-range</code> annotation. The value is a comma separated list of <a href=https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing>CIDRs</a>, e.g. <code>10.0.0.0/24,172.10.0.1</code>.</p> <p>To configure this setting globally for all Ingress rules, the <code>whitelist-source-range</code> value may be set in the <a href=../configmap/#whitelist-source-range>NGINX ConfigMap</a>.</p> <div class="admonition note"> <p class=admonition-title>Note</p> <p>Adding an annotation to an Ingress rule overrides any global restriction.</p> </div> <h3 id=custom-timeouts>Custom timeouts<a class=headerlink href=#custom-timeouts title="Permanent link"></a></h3> <p>Using the configuration configmap it is possible to set the default global timeout for connections to the upstream servers. In some scenarios is required to have different values. To allow this we provide annotations that allows this customization:</p> <ul> <li><code>nginx.ingress.kubernetes.io/proxy-connect-timeout</code></li> <li><code>nginx.ingress.kubernetes.io/proxy-send-timeout</code></li> <li><code>nginx.ingress.kubernetes.io/proxy-read-timeout</code></li> <li><code>nginx.ingress.kubernetes.io/proxy-next-upstream</code></li> <li><code>nginx.ingress.kubernetes.io/proxy-next-upstream-timeout</code></li> <li><code>nginx.ingress.kubernetes.io/proxy-next-upstream-tries</code></li> <li><code>nginx.ingress.kubernetes.io/proxy-request-buffering</code></li> </ul> <p>If you indicate <a href=#backend-protocol>Backend Protocol</a> as <code>GRPC</code> or <code>GRPCS</code>, the following grpc values will be set and inherited from proxy timeouts:</p> <ul> <li><a href=https://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_connect_timeout><code>grpc_connect_timeout=5s</code></a>, from <code>nginx.ingress.kubernetes.io/proxy-connect-timeout</code></li> <li><a href=https://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_send_timeout><code>grpc_send_timeout=60s</code></a>, from <code>nginx.ingress.kubernetes.io/proxy-send-timeout</code></li> <li><a href=https://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_read_timeout><code>grpc_read_timeout=60s</code></a>, from <code>nginx.ingress.kubernetes.io/proxy-read-timeout</code></li> </ul> <p>Note: All timeout values are unitless and in seconds e.g. <code>nginx.ingress.kubernetes.io/proxy-read-timeout: "120"</code> sets a valid 120 seconds proxy read timeout.</p> <h3 id=proxy-redirect>Proxy redirect<a class=headerlink href=#proxy-redirect title="Permanent link"></a></h3> <p>The annotations <code>nginx.ingress.kubernetes.io/proxy-redirect-from</code> and <code>nginx.ingress.kubernetes.io/proxy-redirect-to</code> will set the first and second parameters of NGINX's proxy_redirect directive respectively. It is possible to set the text that should be changed in the <code>Location</code> and <code>Refresh</code> header fields of a <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect>proxied server response</a></p> <p>Setting "off" or "default" in the annotation <code>nginx.ingress.kubernetes.io/proxy-redirect-from</code> disables <code>nginx.ingress.kubernetes.io/proxy-redirect-to</code>, otherwise, both annotations must be used in unison. Note that each annotation must be a string without spaces.</p> <p>By default the value of each annotation is "off".</p> <h3 id=custom-max-body-size>Custom max body size<a class=headerlink href=#custom-max-body-size title="Permanent link"></a></h3> <p>For NGINX, an 413 error will be returned to the client when the size in a request exceeds the maximum allowed size of the client request body. This size can be configured by the parameter <a href=https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size><code>client_max_body_size</code></a>.</p> <p>To configure this setting globally for all Ingress rules, the <code>proxy-body-size</code> value may be set in the <a href=../configmap/#proxy-body-size>NGINX ConfigMap</a>. To use custom values in an Ingress rule define these annotation:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/proxy-body-size</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">8m</span>
</code></pre></div> <h3 id=proxy-cookie-domain>Proxy cookie domain<a class=headerlink href=#proxy-cookie-domain title="Permanent link"></a></h3> <p>Sets a text that <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cookie_domain>should be changed in the domain attribute</a> of the "Set-Cookie" header fields of a proxied server response.</p> <p>To configure this setting globally for all Ingress rules, the <code>proxy-cookie-domain</code> value may be set in the <a href=../configmap/#proxy-cookie-domain>NGINX ConfigMap</a>.</p> <h3 id=proxy-cookie-path>Proxy cookie path<a class=headerlink href=#proxy-cookie-path title="Permanent link"></a></h3> <p>Sets a text that <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cookie_path>should be changed in the path attribute</a> of the "Set-Cookie" header fields of a proxied server response.</p> <p>To configure this setting globally for all Ingress rules, the <code>proxy-cookie-path</code> value may be set in the <a href=../configmap/#proxy-cookie-path>NGINX ConfigMap</a>.</p> <h3 id=proxy-buffering>Proxy buffering<a class=headerlink href=#proxy-buffering title="Permanent link"></a></h3> <p>Enable or disable proxy buffering <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering><code>proxy_buffering</code></a>. By default proxy buffering is disabled in the NGINX config.</p> <p>To configure this setting globally for all Ingress rules, the <code>proxy-buffering</code> value may be set in the <a href=../configmap/#proxy-buffering>NGINX ConfigMap</a>. To use custom values in an Ingress rule define these annotation:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/proxy-buffering</span><span class=p>:</span><span class=w> </span><span class=s>&quot;on&quot;</span>
</code></pre></div> <h3 id=proxy-buffers-number>Proxy buffers Number<a class=headerlink href=#proxy-buffers-number title="Permanent link"></a></h3> <p>Sets the number of the buffers in <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffers><code>proxy_buffers</code></a> used for reading the first part of the response received from the proxied server. By default proxy buffers number is set as 4</p> <p>To configure this setting globally, set <code>proxy-buffers-number</code> in <a href=../configmap/#proxy-buffers-number>NGINX ConfigMap</a>. To use custom values in an Ingress rule, define this annotation: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/proxy-buffers-number</span><span class=p>:</span><span class=w> </span><span class=s>&quot;4&quot;</span>
</code></pre></div></p> <h3 id=proxy-buffer-size>Proxy buffer size<a class=headerlink href=#proxy-buffer-size title="Permanent link"></a></h3> <p>Sets the size of the buffer <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size><code>proxy_buffer_size</code></a> used for reading the first part of the response received from the proxied server. By default proxy buffer size is set as "4k"</p> <p>To configure this setting globally, set <code>proxy-buffer-size</code> in <a href=../configmap/#proxy-buffer-size>NGINX ConfigMap</a>. To use custom values in an Ingress rule, define this annotation: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/proxy-buffer-size</span><span class=p>:</span><span class=w> </span><span class=s>&quot;8k&quot;</span>
</code></pre></div></p> <h3 id=proxy-busy-buffers-size>Proxy busy buffers size<a class=headerlink href=#proxy-busy-buffers-size title="Permanent link"></a></h3> <p><a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_busy_buffers_size>Limits the total size of buffers that can be busy</a> sending a response to the client while the response is not yet fully read.</p> <p>By default proxy busy buffers size is set as "8k".</p> <p>To configure this setting globally, set <code>proxy-busy-buffers-size</code> in the <a href=../configmap/#proxy-busy-buffers-size>ConfigMap</a>. To use custom values in an Ingress rule, define this annotation:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/proxy-busy-buffers-size</span><span class=p>:</span><span class=w> </span><span class=s>&quot;16k&quot;</span>
</code></pre></div> <h3 id=proxy-max-temp-file-size>Proxy max temp file size<a class=headerlink href=#proxy-max-temp-file-size title="Permanent link"></a></h3> <p>When <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering><code>buffering</code></a> of responses from the proxied server is enabled, and the whole response does not fit into the buffers set by the <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size><code>proxy_buffer_size</code></a> and <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffers><code>proxy_buffers</code></a> directives, a part of the response can be saved to a temporary file. This directive sets the maximum <code>size</code> of the temporary file setting the <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_max_temp_file_size><code>proxy_max_temp_file_size</code></a>. The size of data written to the temporary file at a time is set by the <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_temp_file_write_size><code>proxy_temp_file_write_size</code></a> directive.</p> <p>The zero value disables buffering of responses to temporary files.</p> <p>To use custom values in an Ingress rule, define this annotation: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/proxy-max-temp-file-size</span><span class=p>:</span><span class=w> </span><span class=s>&quot;1024m&quot;</span>
</code></pre></div></p> <h3 id=proxy-http-version>Proxy HTTP version<a class=headerlink href=#proxy-http-version title="Permanent link"></a></h3> <p>Using this annotation sets the <a href=https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version><code>proxy_http_version</code></a> that the Nginx reverse proxy will use to communicate with the backend. By default this is set to "1.1".</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/proxy-http-version</span><span class=p>:</span><span class=w> </span><span class=s>&quot;1.0&quot;</span>
</code></pre></div> <h3 id=ssl-ciphers>SSL ciphers<a class=headerlink href=#ssl-ciphers title="Permanent link"></a></h3> <p>Specifies the <a href=https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_ciphers>enabled ciphers</a>.</p> <p>Using this annotation will set the <code>ssl_ciphers</code> directive at the server level. This configuration is active for all the paths in the host.</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/ssl-ciphers</span><span class=p>:</span><span class=w> </span><span class=s>&quot;ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP&quot;</span>
</code></pre></div> <p>The following annotation will set the <code>ssl_prefer_server_ciphers</code> directive at the server level. This configuration specifies that server ciphers should be preferred over client ciphers when using the SSLv3 and TLS protocols.</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/ssl-prefer-server-ciphers</span><span class=p>:</span><span class=w> </span><span class=s>&quot;true&quot;</span>
</code></pre></div> <h3 id=connection-proxy-header>Connection proxy header<a class=headerlink href=#connection-proxy-header title="Permanent link"></a></h3> <p>Using this annotation will override the default connection header set by NGINX. To use custom values in an Ingress rule, define the annotation:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/connection-proxy-header</span><span class=p>:</span><span class=w> </span><span class=s>&quot;keep-alive&quot;</span>
</code></pre></div> <h3 id=enable-access-log>Enable Access Log<a class=headerlink href=#enable-access-log title="Permanent link"></a></h3> <p>Access logs are enabled by default, but in some scenarios access logs might be required to be disabled for a given ingress. To do this, use the annotation:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/enable-access-log</span><span class=p>:</span><span class=w> </span><span class=s>&quot;false&quot;</span>
</code></pre></div> <h3 id=enable-rewrite-log>Enable Rewrite Log<a class=headerlink href=#enable-rewrite-log title="Permanent link"></a></h3> <p>Rewrite logs are not enabled by default. In some scenarios it could be required to enable NGINX rewrite logs. Note that rewrite logs are sent to the error_log file at the notice level. To enable this feature use the annotation:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/enable-rewrite-log</span><span class=p>:</span><span class=w> </span><span class=s>&quot;true&quot;</span>
</code></pre></div> <h3 id=enable-opentelemetry>Enable Opentelemetry<a class=headerlink href=#enable-opentelemetry title="Permanent link"></a></h3> <p>Opentelemetry can be enabled or disabled globally through the ConfigMap but this will sometimes need to be overridden to enable it or disable it for a specific ingress (e.g. to turn off telemetry of external health check endpoints)</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/enable-opentelemetry</span><span class=p>:</span><span class=w> </span><span class=s>&quot;true&quot;</span>
</code></pre></div> <h3 id=opentelemetry-trust-incoming-span>Opentelemetry Trust Incoming Span<a class=headerlink href=#opentelemetry-trust-incoming-span title="Permanent link"></a></h3> <p>The option to trust incoming trace spans can be enabled or disabled globally through the ConfigMap but this will sometimes need to be overridden to enable it or disable it for a specific ingress (e.g. only enable on a private endpoint)</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/opentelemetry-trust-incoming-spans</span><span class=p>:</span><span class=w> </span><span class=s>&quot;true&quot;</span>
</code></pre></div> <h3 id=x-forwarded-prefix-header>X-Forwarded-Prefix Header<a class=headerlink href=#x-forwarded-prefix-header title="Permanent link"></a></h3> <p>To add the non-standard <code>X-Forwarded-Prefix</code> header to the upstream request with a string value, the following annotation can be used:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/x-forwarded-prefix</span><span class=p>:</span><span class=w> </span><span class=s>&quot;/path&quot;</span>
</code></pre></div> <h3 id=modsecurity>ModSecurity<a class=headerlink href=#modsecurity title="Permanent link"></a></h3> <p><a href=http://modsecurity.org/ >ModSecurity</a> is an OpenSource Web Application firewall. It can be enabled for a particular set of ingress locations. The ModSecurity module must first be enabled by enabling ModSecurity in the <a href=../configmap/#enable-modsecurity>ConfigMap</a>. Note this will enable ModSecurity for all paths, and each path must be disabled manually.</p> <p>It can be enabled using the following annotation: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/enable-modsecurity</span><span class=p>:</span><span class=w> </span><span class=s>&quot;true&quot;</span>
</code></pre></div> ModSecurity will run in "Detection-Only" mode using the <a href=https://github.com/SpiderLabs/ModSecurity/blob/v3/master/modsecurity.conf-recommended>recommended configuration</a>.</p> <p>You can enable the <a href=https://www.modsecurity.org/CRS/Documentation/ >OWASP Core Rule Set</a> by setting the following annotation: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/enable-owasp-core-rules</span><span class=p>:</span><span class=w> </span><span class=s>&quot;true&quot;</span>
</code></pre></div></p> <p>You can pass transactionIDs from nginx by setting up the following: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/modsecurity-transaction-id</span><span class=p>:</span><span class=w> </span><span class=s>&quot;$request_id&quot;</span>
</code></pre></div></p> <p>You can also add your own set of modsecurity rules via a snippet: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/modsecurity-snippet</span><span class=p>:</span><span class=w> </span><span class="p p-Indicator">|</span>
<span class="l l-Scalar l-Scalar-Plain">SecRuleEngine On</span>
<span class="l l-Scalar l-Scalar-Plain">SecDebugLog /tmp/modsec_debug.log</span>
</code></pre></div></p> <p>Note: If you use both <code>enable-owasp-core-rules</code> and <code>modsecurity-snippet</code> annotations together, only the <code>modsecurity-snippet</code> will take effect. If you wish to include the <a href=https://www.modsecurity.org/CRS/Documentation/ >OWASP Core Rule Set</a> or <a href=https://github.com/SpiderLabs/ModSecurity/blob/v3/master/modsecurity.conf-recommended>recommended configuration</a> simply use the include statement:</p> <p>nginx 0.24.1 and below <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/modsecurity-snippet</span><span class=p>:</span><span class=w> </span><span class="p p-Indicator">|</span>
<span class="l l-Scalar l-Scalar-Plain">Include /etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf</span>
<span class="l l-Scalar l-Scalar-Plain">Include /etc/nginx/modsecurity/modsecurity.conf</span>
</code></pre></div> nginx 0.25.0 and above <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/modsecurity-snippet</span><span class=p>:</span><span class=w> </span><span class="p p-Indicator">|</span>
<span class="l l-Scalar l-Scalar-Plain">Include /etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf</span>
</code></pre></div></p> <h3 id=backend-protocol>Backend Protocol<a class=headerlink href=#backend-protocol title="Permanent link"></a></h3> <p>Using <code>backend-protocol</code> annotations is possible to indicate how NGINX should communicate with the backend service. (Replaces <code>secure-backends</code> in older versions) Valid Values: HTTP, HTTPS, AUTO_HTTP, GRPC, GRPCS and FCGI</p> <p>By default NGINX uses <code>HTTP</code>.</p> <p>Example:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/backend-protocol</span><span class=p>:</span><span class=w> </span><span class=s>&quot;HTTPS&quot;</span>
</code></pre></div> <h3 id=use-regex>Use Regex<a class=headerlink href=#use-regex title="Permanent link"></a></h3> <div class="admonition attention"> <p class=admonition-title>Attention</p> <p>When using this annotation with the NGINX annotation <code>nginx.ingress.kubernetes.io/affinity</code> of type <code>cookie</code>, <code>nginx.ingress.kubernetes.io/session-cookie-path</code> must be also set; Session cookie paths do not support regex.</p> </div> <p>Using the <code>nginx.ingress.kubernetes.io/use-regex</code> annotation will indicate whether or not the paths defined on an Ingress use regular expressions. The default value is <code>false</code>.</p> <p>The following will indicate that regular expression paths are being used: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/use-regex</span><span class=p>:</span><span class=w> </span><span class=s>&quot;true&quot;</span>
</code></pre></div></p> <p>The following will indicate that regular expression paths are <strong>not</strong> being used: <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/use-regex</span><span class=p>:</span><span class=w> </span><span class=s>&quot;false&quot;</span>
</code></pre></div></p> <p>When this annotation is set to <code>true</code>, the case insensitive regular expression <a href=https://nginx.org/en/docs/http/ngx_http_core_module.html#location>location modifier</a> will be enforced on ALL paths for a given host regardless of what Ingress they are defined on.</p> <p>Additionally, if the <a href=#rewrite><code>rewrite-target</code> annotation</a> is used on any Ingress for a given host, then the case insensitive regular expression <a href=https://nginx.org/en/docs/http/ngx_http_core_module.html#location>location modifier</a> will be enforced on ALL paths for a given host regardless of what Ingress they are defined on.</p> <p>Please read about <a href=../../ingress-path-matching/ >ingress path matching</a> before using this modifier.</p> <h3 id=satisfy>Satisfy<a class=headerlink href=#satisfy title="Permanent link"></a></h3> <p>By default, a request would need to satisfy all authentication requirements in order to be allowed. By using this annotation, requests that satisfy either any or all authentication requirements are allowed, based on the configuration value.</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/satisfy</span><span class=p>:</span><span class=w> </span><span class=s>&quot;any&quot;</span>
</code></pre></div> <h3 id=mirror>Mirror<a class=headerlink href=#mirror title="Permanent link"></a></h3> <p>Enables a request to be mirrored to a mirror backend. Responses by mirror backends are ignored. This feature is useful, to see how requests will react in "test" backends.</p> <p>The mirror backend can be set by applying:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/mirror-target</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">https://test.env.com$request_uri</span>
</code></pre></div> <p>By default the request-body is sent to the mirror backend, but can be turned off by applying:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/mirror-request-body</span><span class=p>:</span><span class=w> </span><span class=s>&quot;off&quot;</span>
</code></pre></div> <p>Also by default header Host for mirrored requests will be set the same as a host part of uri in the "mirror-target" annotation. You can override it by "mirror-host" annotation:</p> <div class=highlight><pre><span></span><code><span class=nt>nginx.ingress.kubernetes.io/mirror-target</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">https://1.2.3.4$request_uri</span>
<span class=nt>nginx.ingress.kubernetes.io/mirror-host</span><span class=p>:</span><span class=w> </span><span class=s>&quot;test.env.com&quot;</span>
</code></pre></div> <p><strong>Note:</strong> The mirror directive will be applied to all paths within the ingress resource.</p> <p>The request sent to the mirror is linked to the original request. If you have a slow mirror backend, then the original request will throttle.</p> <p>For more information on the mirror module see <a href=https://nginx.org/en/docs/http/ngx_http_mirror_module.html>ngx_http_mirror_module</a></p> <h3 id=stream-snippet>Stream snippet<a class=headerlink href=#stream-snippet title="Permanent link"></a></h3> <p>Using the annotation <code>nginx.ingress.kubernetes.io/stream-snippet</code> it is possible to add custom stream configuration.</p> <div class=highlight><pre><span></span><code><span class=nt>apiVersion</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">networking.k8s.io/v1</span>
<span class=nt>kind</span><span class=p>:</span><span class=w> </span><span class="l l-Scalar l-Scalar-Plain">Ingress</span>
<span class=nt>metadata</span><span class=p>:</span>
<span class=w> </span><span class=nt>annotations</span><span class=p>:</span>
<span class=w> </span><span class=nt>nginx.ingress.kubernetes.io/stream-snippet</span><span class=p>:</span><span class=w> </span><span class="p p-Indicator">|</span>
<span class=w> </span><span class=no>server {</span>
<span class=w> </span><span class=no>listen 8000;</span>
<span class=w> </span><span class=no>proxy_pass 127.0.0.1:80;</span>
<span class=w> </span><span class=no>}</span>
</code></pre></div> </article> </div> </div> </main> <footer class=md-footer> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class=md-copyright> Made with <a href=https://squidfunk.github.io/mkdocs-material/ target=_blank rel=noopener> Material for MkDocs </a> </div> </div> </div> </footer> </div> <div class=md-dialog data-md-component=dialog> <div class="md-dialog__inner md-typeset"></div> </div> <script id=__config type=application/json>{"base": "../../..", "features": ["navigation.tabs", "navigation.tabs.sticky", "navigation.instant", "navigation.sections"], "search": "../../../assets/javascripts/workers/search.f886a092.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script> <script src=../../../assets/javascripts/bundle.aecac24b.min.js></script> </body> </html>