<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 7, 2023 at 2:56 AM Francis Daly <<a href="mailto:francis@daoine.org">francis@daoine.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Jan 05, 2023 at 10:15:34PM +0530, Kaushal Shriyan wrote:<br>
<br>
Hi there,<br>
<br>
> When I hit <a href="http://mydomain.com/apis" rel="noreferrer" target="_blank">http://mydomain.com/apis</a> for conditions when MySQL DB is down. I<br>
> get the below output and it works as expected.<br>
> <br>
> {"errors": "MySQL DB Server is down"}<br>
> <br>
> When I hit <a href="http://mydomain.com/apis" rel="noreferrer" target="_blank">http://mydomain.com/apis</a> for conditions when MySQL DB is up and<br>
> running fine, I get the below output in spite of MySQL DB server being<br>
> fine.<br>
> <br>
> {"errors": "MySQL DB Server is down"}<br>
<br>
Your config is<br>
<br>
location /apis {<br>
return 500 '{"errors": "MySQL DB Server is down"}';<br>
}<br>
<br>
Whenever you make a request that is handled in that location{}, your<br>
nginx will return that response.<br>
<br>
It looks like your nginx is doing what it was told to do.<br>
<br>
No part of your config indicates that nginx knows (or cares) whether<br>
MySQL DB is up or down. Does something outside of nginx know that?<br>
<br>
f<br>
-- <br>
Francis Daly <a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a><br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="https://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">https://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote><div><br></div><div><br></div>Thanks Francis for the detailed explanation. Is there a way to configure Nginx for the below conditions?<br><br>When I hit <a href="http://mydomain.com/apis">http://mydomain.com/apis</a> for conditions when MySQL DB is down. I get the below output and it works as expected.<br><br>{"errors": "MySQL DB Server is down"}<br><br>When I hit <a href="http://mydomain.com/apis">http://mydomain.com/apis</a> for conditions when MySQL DB is up and running fine, I get the below output in spite of MySQL DB server being fine.<br><br>{"errors": "MySQL DB Server is down"}</div><div class="gmail_quote"> </div><div class="gmail_quote">Please suggest. Thanks in advance. I appreciate your help as always. <br></div><div class="gmail_quote"><span class="gmail-im" style="color:rgb(80,0,80)"><div><br></div><div>Best Regards,</div><div><br></div><div>Kaushal</div></span></div></div>