title: mojolicious does not work in non-blocking way
body: <p>At first, I'm sorry I'm not good at English.</p>
  
  <p>I'm making a Mojolicious app.</p>
  
  <p>My controller does some job using Mojo::UserAgent and uses the result when it makes the output.</p>
  
  <pre><code>my $ua = Mojo::UserAgent-&gt;new();
  my $tx = $ua-&gt;head( $location );
  my $result;
  
  if ( $tx-&gt;res-&gt;code eq '200' ) {
      $result = 'good';
  }
  else {
      $result = 'bad';
  }
  
  # pass the result to the renderer's stash
  $self-&gt;render( result =&gt; $result );
  </code></pre>
  
  <p>This code works well. <strong>It works on both my local machine and the server</strong>.</p>
  
  <p>Next, I tried to make this <code>$ua-&gt;head()</code> non-blocking way, because it could take long time to complete. (I'm a novice and this is my first time to try non-blokcing code using Mojo, for your reference)</p>
  
  <pre><code>my $ua = Mojo::UserAgent-&gt;new();
  my $result;
  
  $self-&gt;render_later;
  $ua-&gt;head( $location =&gt; sub {
      my ($ua, $tx) = @_;
  
      if ( $tx-&gt;res-&gt;code eq '200' ) {
          $result = 'good';
      }
      else {
          $result = 'bad';
      }
      $self-&gt;render( result =&gt; $result );
  });
  Mojo::IOLoop-&gt;start unless Mojo::IOLoop-&gt;is_running;
  </code></pre>
  
  <p><strong>This approach also works well in my local machine</strong> (MacBook OSX 10.9.4, Perl 5.18, Standalone using morbo).</p>
  
  <p>However, <strong>when I launch this code in the server, the server respond with "404 not found".</strong></p>
  
  <p>This server uses Nginx proxy, which forwards requests to working nodes.</p>
  
  <p><code>browser -- Nginx -- Mojolicious App</code></p>
  
  <p>So, I guess this proxy is related to my problem, but I have no idea how to fix it. I don't know even where I have to start from to find the exact cause.</p>
  
  <p>Any advice would be appreciated.</p>
  
  <p>P.S. I should have said "blocking method" works well both on my local machine and on the server. Only "non-blocking method" shows this problem.</p>
  
  <p>Update (2014-08-21) : One of my friends who is a skillful Perl engineer said to me that it seems to be the problem between the event loop of Mojo and that of PSGI, that is, something like a compatibility problem. I can't understand what he said currently, but I'm trying to study more.</p>