title: nginx: Do not require Basic Authentication only if http request is OPTIONS
body: <p>The Authorization Header is not sent with an HTTP OPTIONS Request. I would like disable this authentication only when the request is OPTIONS and leave it on for other requests. Here is the relevant piece of config code I have at the moment.  cannot seem to see why it does not work. I always get a 401 Unauthorized Error on OPTIONS request.</p>
  
  <pre><code>    location ~ /foo/bar
      {
  
        if ($request_method = OPTIONS) {
          set $auth_basic "off";
        }
        if ($request_method != OPTIONS)
        {
          set $auth_basic "Resctricted";
          set $auth_basic_user_file /var/www/.htpasswd;
        }
        auth_basic $auth_basic;
        auth_basic_user_file $auth_basic_user_file;
      }
  </code></pre>