502 Proxy error when trying to use Homebrew php72 with Server.app websites

apachehomebrewPHPPROXYserver.app

I'm having a puzzling issue with a website on macOS server (server.app 5.6, High Sierra 10.13).

All works fine when the url length is below 70 characters. 70 and up and I'm getting a Proxy error.
The actual absolute path char count respectively <= 94 – works, > 94 – Error

enter image description here

Can there be a limit set somewhere?

EDIT

Seems to be related to change of the PHP from system to Homebrew.

EDIT 2

The OS PHP version shipped with the Server.app is 7.1.32 ā€“ it works but is missing the intl extension that I need for a Magento 2.3.3 project
(I think intl is shipped with the Server.app or MacOS/Xcode but inactive by default)

The Homebrew PHP version that I was trying to use: 7.2.25

The MySQL version: 8.0.16 (Oracle community)
The MySQL actually says that it's compiled for MacOS 10.14 and I run MacOS 10.13, not sure if that is important)

EDIT 3

After more testing I noticed the error pops-up also with shorter, simple urls, random pages, without any pattern really (when using Homebrew PHP).

I've compared the php.ini from OS and Homebrew installations with a diff but failed to find any significant differences. The error appears even on a simple WordPress websites that don't use any of the advanced php extensions.

I've got the same Homebrew PHP installed on my other Mac, same OS but also Homebrew MySQL and without the proxy ā€“ it works fine.

Best Answer

Trying to get to the bottom of that... most likely the issues are related with the specific configuration of the bundled Apache server on MacOS.

I think the only solution would be re-installing Apache with eg. Homebrew, which is effectively migrating away from the outdated Server.app.