title: Setting up proxy_pass on nginx to make API calls to API Gateway
body: <h1>Problem:</h1>
  <p>I've set up a Lambda function behind API gateway which works beautifully. I have a hosted site that I want only a certain location to hit the API.</p>
  <h3>Example</h3>
  <p><a href="https://www.example.com/" rel="nofollow noreferrer">https://www.example.com/</a> (Serves up html from hosted server)</p>
  <p><a href="https://www.example.com/foobar" rel="nofollow noreferrer">https://www.example.com/foobar</a> (Returns a JSON payload that is generated by Lambda and returned by AWS)</p>
  <p>Here is my server block:</p>
  <pre><code>   location = /foobar {
              proxy_pass     https://someawsuri;
              proxy_redirect default;
      }
  
      location / {
              # First attempt to serve request as file, then
              # as directory, then fall back to displaying a 404.
              try_files $uri $uri/ =404;
      }
  </code></pre>
  <p>I've tried reviewing the docs and read multiple SO posts, but I haven't been able to do what I want. Everything that I've tried has produced the error <code>502 Bad Gateway</code>.</p>
  <h1>Question:</h1>
  <p>How do I configure nginx to make a request to API gateway?</p>
  <p>Thanks.</p>