title: How to properly setup nginx Access-Control-Allow-Origin into response header based on the Origin header from the request?
body: <p>I am looking for a nginx config setup that does setup the <code>Access-Control-Allow-Origin</code> to the value received in the <code>Origin</code>.</p>
  
  <p>It seems that the <code>*</code> method doesn't work with Chrome and the multiple URLs doesn't work with Firefox as it is not allowed by CORS specification. </p>
  
  <p>So far, the only solution is to setup the <code>Access-Control-Allow-Origin</code> to the value received in the origin (yes some validation could be implemented).</p>
  
  <p>The question is how to do this in nginx, preferably without installing additional extensions.</p>
  
  <pre><code>set $allow_origin "https://example.com"
  # instead I want to get the value from Origin request header
  add_header 'Access-Control-Allow-Origin' $allow_origin;
  </code></pre>