title: Nginx: Redirect all but one
body: <p>I have the following http config:</p>
  
  <pre><code>server {
    listen                80;
    server_name           example.com;
  
    # Necessary for Let's Encrypt Domain Name ownership validation
    location /.well-known/acme-challenge/ {
      root /home/vagrant/.well-known/acme-challenge/;
    }
  
    return 301 https://$host$request_uri;
  }
  </code></pre>
  
  <p>I would like <code>http://example.com/.well-known/acme-challenge/filename</code> to serve <code>/home/vagrant/.well-known/acme-challenge/filename</code> while every other http request should be redirected to https.</p>
  
  <p>I thought Nginx would process rules in their order, if matches, uses it, otherwise continues. But apparently not. How can I achieve what I want ? </p>