serve different content according to header value in Nginx
<p>I have some web content behind the follwoing arch, for which I need to serve different content for desktop and mobile clients.</p>

<p>client > AWS Cloudfront > Nginx > ...</p>

<p>cloudfront has the builtin ability to identify the user-agent and they kind of unify it into 4 special headers (for example CloudFront-Is-Desktop-Viewer) which are either true or false.</p>

<p>on Nginx I'm trying to decide which content to serve according to those headers.
for example:</p>

<pre><code> location / {
   if ($http_CloudFront-Is-Desktop-Viewer = true) {
        proxy_pass http://upstream;
        break;
   }
   root /var/www/static/en-US;
   try_files $uri /index.html;
 }
</code></pre>

<p>so in the above case it should go to the upstream if the CloudFront-Is-Desktop-Viewer value is true, and get the static files from nginx if it's false or not present.</p>

<p>but for some reason I always get the static files from nginx.
I'm sure this header is being forwarded, I've even tried to send it directly from chrome with a header modifier.</p>

<p>what am i missing?</p>

<p>many thanks</p>