title: What is the best way to upload files to another domain from a browser?
body: <p>I am creating a web service of scheduled posts to some social network.<br>Need help dealing with file uploads under high traffic.</p>
  
  <p><strong>Process overview:</strong></p>
  
  <ul>
  <li>User uploads files to SomeServer (not mine). </li>
  <li>SomeServer then responds with a JSON string.</li>
  <li>My web app should store that JSON response.</li>
  </ul>
  
  <p><strong>Option 1: Save, cURL POST, delete tmp</strong><br>
  The <strike>stupid</strike> way I made it work:</p>
  
  <ol>
  <li>User uploads files to MyWebApp;</li>
  <li>MyWebApp cURL's the file further to SomeServer, getting the response.</li>
  </ol>
  
  <p><strong>Option 2: JS magic</strong><br>
  The smart way it could be perfect:</p>
  
  <ol>
  <li>User uploads the file directly to SomeServer, from within an iFrame;</li>
  <li>MyWebApp gets the response through JavaScript.</li>
  </ol>
  
  <p>But this is(?) impossible due to the 'Same Origin Policy', isn't it?</p>
  
  <p><strong>Option 3: nginx proxying?</strong><br>
  The better way for a production server:</p>
  
  <ol>
  <li>User uploads files to MyWebApp;</li>
  <li>nginx intercepts the file uploads and sends them directly to the SomeServer;</li>
  <li>JSON response is also intercepted by nginx and processed by MyWebApp.</li>
  </ol>
  
  <p>Does this make any sense, and what would be the nginx config for, say, <code>/fileupload</code> Location to proxy it to SomeServer?</p>