title: Making a POST request to an external URL from a django + gunicorn + nginx setup
body: <p>I am sending a post request from a method inside a web application running on django+nginx+gunicorn. I have no issues receiving 200 response from the same code when executed on django's own server (using runserver).</p>
  
  <pre><code>try:
      response = requests.post(post_url, data=some_data)
      if response.status_code == OK and response.content == '':
          logger.info("Request successful")
      else:
          logger.info("Request failed with response({}): {}".format(response.status_code, response.content))
          return response.status_code == OK and response.content == ''
  except requests.RequestException as e:
      logger.info("Request failed with exception: {}".format(e.message))
      return False
  </code></pre>
  
  <p>I checked the server logs at post_url, it is indeed returning 200 response with this data. However, when I run the app behind gunicorn and nginx, I am not able to receive the response, (however the request is being sent). The code gets stuck at the first line after the try block, and gunicorn worker times out (after 30 seconds). </p>
  
  <p>This is the apache server log at the post_url:</p>
  
  <pre><code>[14/Sep/2016:13:19:20 +0000] "POST POST_URL_PATH HTTP/1.0" 200 295 "-" "python-requests/2.9.1"
  </code></pre>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p>I forgot to mention, this request takes less than a second to execute, so it is not a timeout issue. Something is wrong with the configuration? I have the standard nginx+gunicorn setup, where gunicorn is set as the proxy_pass in nginx. I am guessing since I am behind a nginx proxy, should I be doing something different while sending a post request from the application?</p>