<h2>The problem</h2>

<p>The pipe character does not seem to work in Istio's <code>VirtualService</code>.</p>

<p>The example below is intended to route requests based on the <code>user-agent</code> header. Requests from a mobile device should go to <code>myapp</code> and requests from a desktop user should go to <code>deskt-app</code>, handled by next match block. The <code>&lt;REGEX&gt;</code> field works when I use this regex:</p>

<ul>
<li><code>^.*\bMobile\b.*$</code></li>
</ul>

<p>But the powers that be require a more sophisticated regex to identify mobile users. My routing breaks entirely when I use these:</p>

<ul>
<li><code>^.*\b(iPhone|Pixel)\b.*$</code></li>
<li><code>^.*\b(iPhone|Pixel)+\b.*$</code></li>
<li><code>^.*\biPhone|Pixel\b.*$</code></li>
</ul>

<h2>Expected behavior</h2>

<p>Using a regex with a pipe (logical OR) I expect to be routed to <code>myapp</code> when I have a <code>user-agent</code> header that contains the word "iPhone" or "Pixel".</p>

<h2>Actual behavior</h2>

<p>I get routed to <code>deskt-app</code>.</p>

<h2>The question</h2>

<p>How do I achieve a logical OR in an Istio <code>VirtualService</code> regex pattern? And is that my problem or am I overlooking something obvious?</p>

<hr>

<h2>Example <code>VirtualService</code></h2>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
  ...
  ...
  http:
  - match:
    - headers:
        user-agent:
          regex: "&lt;REGEX&gt;"    &lt;------
      uri:
        prefix: /foo/bar
    route:
    - destination:
        host: myapp
        port:
          number: 80
  - match:
    - uri:
        prefix: /foo/bar
    route:
    - destination:
        host: deskt-app
        port:
          number: 80
</code></pre>

<hr>

<p>EDIT: <a href="https://github.com/istio/istio/issues/10766" rel="nofollow noreferrer">Github Issue</a></p>

<p>Your configuration is correct, so the issue must be with the Regex, or the contents of the user-agent are different, give this a try <code>'^.*(iPhone|Pixel).*$'</code></p>

<p>Just verified that the configuration below routes correctly when the header contains android or iphone:</p>

<pre><code>  - match:
    - headers: 
        user-agent: 
            regex: '^.*(Android|iPhone).*$'
</code></pre>

<p>And tested with:</p>

<p><strong>[match]</strong> curl -H "user-agent: Mozilla/5.0 (Linux; U; iPhone 4.4.2; en-us;)" ... </p>

<p><strong>[no match]</strong> curl -H "user-agent: Mozilla/5.0 (Linux; U; Iphne 4.4.2; en-us;)" ...</p>
