title: Use conditional mirror in Nginx
body: <p>Here is my Nginx configuration:</p>
  <pre><code>upstream backend {
      server backend.local:10000;
  }
  
  upstream test_backend {
      server test.local:20000;
  }
  
  server {
      server_name proxy.local;
      listen 8000;
  
      location / {
          if ($http_authorization != &quot;&quot;) {
              mirror /mirror;
          }
          proxy_pass http://backend;
      }
  
      location = /mirror {
          internal;
          proxy_pass http://test_backend$request_uri;
      }
  }
  </code></pre>
  <p>As you can see, I tried to wrap the <code>mirror</code> block with a condition. Basically I need to mirror the request whenever the <code>Authorization</code> header is set. Nginx shows and error when I try to use this config which tells me that I can't use <code>mirror</code> inside an <code>if</code> statement. How can I mirror the request conditionally?</p>