<p>I have a integration Kubernetes cluster in AWS, and I want to conduct end-to-end tests on that cluster. </p>

<p>I currently use Deployments and Services.</p>

<p>The proposed approach is to use Ingress and configure it to use cookie injection for ensuring access to web page that implements the following logic:</p>

<ol>
<li><p>When <em>special</em> header is recognized in request -> allow the agent to enter the webpage (used for automated tests)</p></li>
<li><p>When <em>special</em> header is not recognized in request -> display popup for basic http authentication (used for normal users).</p></li>
</ol>

<p>I also want to use a single entry point for both cases (the same url).</p>

<p>I've been browsing official documentation, but didn't find the specified use case, nor did I find any examples that might be close to what I want to achieve.</p>

<p>I'm interested if anyone has used similar approach or something that might be similar in use.</p>

<p>Many thanks!</p>

<p>It sounds like either <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#configuration-snippet" rel="nofollow noreferrer">configuration-snippet</a> or a full-blown <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/custom-template/" rel="nofollow noreferrer">custom template</a> may do what you want, along with the nginx <a href="http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#if" rel="nofollow noreferrer"><code>if</code></a> and <a href="http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header" rel="nofollow noreferrer"><code>add_header</code></a> using something like:</p>

<pre><code>if ($http_user_agent ~ "My Sekrit Agent/666") {
    add_header Authentication "Basic dXNlcm5hbWU6cGFzc3dvcmQ=";
}
</code></pre>
