Have you ever been working with Guzzle, php-fpm and Nginx and then as soon as you send a request via the Guzzle client you get a "502 Bad Gateway"?
Well, that's how I spent 2 working days this week, absolutely everything in our code looked fine, running it via a PHP script on the terminal wasn't a problem, but as soon as we used the same code within our development Docker containers, boom, 502.
After drilling down into the code for the Guzzle
CurlHandler for what seemed like an age, I eventually noticed something that piqued my interest: Guzzle was trying to write to write to
php://temp if you don't provide a
sink option in the construction of the
Client (the code that covers this: https://github.com/guzzle/guzzle/blob/master/src/Handler/CurlFactory.php#L350-L372)
This got me thinking, "I wonder if Alpine Linux creates the same
/tmp folder that Ubuntu et-al do?", turns out, no they don't. After creating the
/tmp directory to match where PHP believed the stream for
php://temp should go everything worked like a charm...at least from the Guzzle standpoint.
I hope this helps someone else out there, but if not, it's at least a reminder for me if I ever see Guzzle segfault on me again...