title: add header to response in nginx location directive
body: <p>I try to add a response header to only one location path served and have an nginx config looks like</p>
  
  <pre><code>server {
      ...
      add_header x-test test;
      location /my.img {
          rewrite ^/my.img$ /119.img;
          add_header x-amz-meta-sig 1234567890abcdef;
      }
  }
  </code></pre>
  
  <p>But only the top-level header (x-test) is effective, the one within the location directive does not show up as shown in</p>
  
  <pre><code>$ curl -v -o /tmp/test.img 'https://www.example.com/my.img'
  &lt; HTTP/1.1 200 OK
  &lt; Server: nginx/1.9.3 (Ubuntu)
  &lt; Date: Sun, 14 May 2017 23:58:08 GMT
  &lt; Content-Type: application/octet-stream
  &lt; Content-Length: 251656
  &lt; Last-Modified: Fri, 03 Mar 2017 04:57:47 GMT
  &lt; Connection: keep-alive
  &lt; ETag: "58b8f7cb-3d708"
  &lt; x-test: test
  &lt; Accept-Ranges: bytes
  &lt; 
  { [16104 bytes data]
  </code></pre>
  
  <p>How to send back a custom headrr only for the specific file served.</p>