I'd be interested to see why your POSTs are getting 302 responses almost immediately.
Can you post the request and response headers for both the upload & 302, and for the 501 error? I think what's going on is that 1) your redirection is turning a POST into a GET (which the AJAX configuration doesn't recognize as valid), or 2) AJAX is not able to follow the resultant redirections properly.
When you access the site "directly" and it works, are you doing so using just HTTP? And when you do, does the server typically respond to the upload POST with a 302 or a 200?