title: Is it possible to call external scripts and retrieve output using nginx?
body: <p>My site has a search function at <code>/search/</code>. For every search request captured by nginx, I want to run a Python script and have nginx behave differently depending on the output of said script, whether it's the exit code or stdout. So something like this (pseudocode):</p>
  
  <pre><code>location ~* "/search/(.*)" {
      set redirect_request = call "/usr/bin/python /home/me/script.py $1";
  
      if ($redirect_request = 1) {
          rewrite ^ /page;
      }
  }
  </code></pre>
  
  <p>Is anything like this possible at all with nginx?</p>