On Saturday 25 February 2023 at 11:43:17, Kaushal Shriyan wrote:
> Hi,
>
> Is there a way to configure apache httpd 2.4.55 as per the below flow when
> the below conditions occurs
>
> User -> Apache Web Server -> PHP-FPM Upstream server -> MySQL DB
>
> *Condition 1 when MySQL DB is down*
> When MySQL DB is down, httpd to render JSON output when invoking
> http://mydomain.com/apis by the user using postman rest api client.
> JSON Output
> {"status_code": 500, "status" : "MySQL DB Server is down"}
>
> HTML Output
> HTML output when invoking http://mydomain.com/apis using client browser.
>
> *Condition 2 when PHP-FPM is down*
> When PHP-FPM Upstream server is down, httpd to render JSON output when
> invoking http://mydomain.com/apis by the user using postman rest api
> client. JSON Output
> {"status_code": 502, "status": "php-fpm server is down"}}';
>
> HTML Output
> HTML output when invoking http://mydomain.com/apis using client browser.
I would say that this depends primarily on what API (CGI script?) you are
running on the Apache server. Yes, such a script can generate the JSON you
specified, provided:
a) it has some way of detecting when the PHP-FPM upstream server is "down"
b) it has some way of asking the PHP-FPM upstream server whether the MySQL DB
server is "down"
You also don't say what you want to happen when neither of those servers is
down, however I suspect that in this case you simply want Apache to act as a
reverse proxy and feed back to the client whatever it got from the PHP-FPM
server. That should be a simple case for any CGI script which can do the
exceptions outlined above.
Without a CGI script, Apache can only be a reverse proxy in the above
configuration, and pass back to the client whatever it got from the PHP-FPM
server, so if this is genuinely "down", there won't be anything to create the
JSON you want.
Antony.
--
The GNU General Public Licence was first published on this day in 1989
https://www.gnu.org/licences/gpl.html
Please reply to the list;
please *don't* CC me.
-
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org