title: nginx No 'Access-Control-Allow-Origin' header is present on the requested resource
body: <p>I found that there is lot of such questions but I found no one making me solve my problem.</p>
  
  <pre><code>jQuery.post( 'http://example.com/api_offer/get_time_left', function(data) {
  
      console.log('get time');
  
  }, 'json');
  </code></pre>
  
  <p>I am getting in chrome console this:</p>
  
  <p>XMLHttpRequest cannot load <a href="http://example.com/api_offer/get_time_left" rel="nofollow">http://example.com/api_offer/get_time_left</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '[my local domain]' is therefore not allowed access. </p>
  
  <p>In the nginx site config there is set such settings:</p>
  
  <pre><code>location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_read_timeout 300;
  
                add_header Access-Control-Allow-Origin *;
  
                proxy_set_header Access-Control-Allow-Origin $http_origin;
  
          }
  </code></pre>
  
  <p>I am using Vagrant if that matters. But I get same error if I try to run this it unix server, not my localhost computer.</p>
  
  <p>Tried looking at error logs of nginx and of and of this site domain but found nothing useful.</p>
  
  <p>How can it not work if I have set * to allow any domain? What else can I do about this?</p>