Welcome! Log In Create A New Profile

Advanced

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

All files from this thread

File Name File Size   Posted by Date  
nginxtest.conf 7.2 KB open | download kaushalshriyan 12/15/2022 Read message
nginxtest.conf 7.2 KB open | download kaushalshriyan 12/16/2022 Read message
nginxtest.conf 7.7 KB open | download kaushalshriyan 01/04/2023 Read message
December 16, 2022 01:24PM
Hi Maxim,

I have a follow up question regarding the settings below in nginx.conf
where the php-fpm upstream server is processing all php files for Drupal
CMS.

fastcgi_intercept_errors off
proxy_intercept_errors off

User -> Nginx -> php-fpm -> MySQL DB.

For example if the php-fpm upstream server is down then nginx should render
502 bad gateway
if MySQL DB service is down then nginx should render
500 ISE.

Is there a way to render any of the messages or any custom messages to the
User from the php-fpm upstream server that should be passed to a client
without being intercepted by the Nginx web server. Any examples? I have
attached the file for your reference. Please guide me. Thanks in advance.

Best Regards,

Kaushal

On Fri, Dec 16, 2022 at 7:22 AM Kaushal Shriyan <kaushalshriyan@gmail.com>
wrote:

>
>
> On Fri, Dec 16, 2022 at 1:38 AM Maxim Dounin <mdounin@mdounin.ru> wrote:
>
>> Hello!
>>
>> On Thu, Dec 15, 2022 at 09:53:11PM +0530, Kaushal Shriyan wrote:
>>
>> >
>> > I am running the nginx version: nginx/1.22 as a reverse proxy server on
>> > CentOS Linux release 7.9.2009 (Core). When I hit
>> http://mydomain.com/apis I
>> > see the below message on the browser even if the upstream server php-fpm
>> > server is up and running.
>> >
>> > *{"errors": {"status_code": 502,"status": "php-fpm server is down"}}*
>> >
>> > I have set the below in the nginx.conf file and attached the file for
>> your
>> > reference.
>> >
>> > if ($upstream_http_content_type = "") {
>> > add_header 'Content-Type' 'application/json'
>> always;
>> > add_header 'Content-Type-3'
>> > $upstream_http_content_type$isdatatypejson"OK" always;
>> > return 502 '{"errors": {"status_code":
>> 502,"status":
>> > "php-fpm server is down"}}';
>> > }
>>
>> The "if" directive makes it possible to conditionally select
>> configuration to handle a request, and therefore can only use
>> information available before the request is handled. In your
>> case, before the request is sent to the upstream server. See
>> http://nginx.org/en/docs/http/ngx_http_rewrite_module.html for
>> more details.
>>
>> As such, $upstream_http_content_type will be always empty, since
>> there are no upstream response yet, and therefore the
>> configuration will always return 502. This matches your
>> observations.
>>
>> An obvious fix would be to remove the configuration chunk in
>> question.
>>
>> Instead, you probably need something like:
>>
>> error_page 502 /502.json;
>>
>> location = /502.json {
>> return 200 '{"errors": {"status_code": 502, "status": "php-fpm
>> server is down"}}';
>> }
>>
>>
> Thanks Maxim for the suggestion. I will try it out and keep you posted
> with the testing as it progresses. I am obliged to this mailing list.
> Thanks in advance.
>
> Best Regards,
>
> Kaushal
>
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Attachments:
open | download - nginxtest.conf (7.2 KB)
Subject Author Posted

Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

kaushalshriyan December 15, 2022 11:24AM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}} Attachments

kaushalshriyan December 15, 2022 11:28AM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

Maxim Dounin December 15, 2022 03:10PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

kaushalshriyan December 15, 2022 08:54PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}} Attachments

kaushalshriyan December 16, 2022 01:24PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

Maxim Dounin December 16, 2022 05:20PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

Maxim Dounin December 21, 2022 08:36PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}} Attachments

kaushalshriyan January 04, 2023 12:24PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

kaushalshriyan January 05, 2023 11:46AM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

Francis Daly January 06, 2023 04:26PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

kaushalshriyan January 06, 2023 10:00PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

Dan Swaney January 07, 2023 12:10PM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

Francis Daly January 09, 2023 04:24AM

Re: Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

Dan Swaney January 05, 2023 01:48PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 296
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready