It is a bad idea to use both RewindableInput and StringIO. StringIO buffer the POST body in memory (in a string, bad for large post). RewindableInput buffer POST body in a temp file, which is very slow. Using both is like getting the worse part from both.
what error message do you get with
rack_input = RewindableInput.new($stdin)
Seems it work in my environment.