502 Error on WP CMS on GCP NGINX

Type: Bitnami Support Tool

Description:
Please note that I am unable to run the bitnami tool as it persistently gives an error. I have created a separate ticket for that

For this request, here’s the Bitnami code 13814ad0-7115-02b8-6e36-02b417b59ad2

When I navigate to http://domain.com/wp-admin
WP CMS redirects to
https://domain.com/wp-login.php?redirect_to=https%3A%2F%2Fdomain.com%2Fwp-admin%2F&reauth=1
And displayed a 502 nginx error
I have tried troubleshooting to no avail.
Everything points to an improper nginx and php configuration with this stack.I have not made any customizations except for updating WPCMS.
I have looked at these two articles which have a similar issue but unable to resolve
https://armno.medium.com/til-fixing-http-502-bad-gateway-error-nginx-wordpress-a591be919adf
https://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm/

Can you assist with this?

Hello @codepantry,

There may be several reasons for this issue. I would suggest enable WordPress debug mode to get more information (in your wp-config.php file):

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );

As a temporary workaround, you can access to http://domain.com/wp-login.php.

I hope it helps

I did not mention in the above comments but I am aware of the workaround and it is how I have been able to proceed. Also I did not metntion but I already tried activating the debug options for WP CMS and what happens is with debug turned on, this error does not show at all. It logs in soothly. When you turn debug off, the error shows. Nothing is recorded in the logs with hints on the source of the error

This is why after all this research, I came across these two links and created this ticket this way. Did you review them to see if this is the issue?
https://armno.medium.com/til-fixing-http-502-bad-gateway-error-nginx-wordpress-a591be919adf
https://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm/

When I turn off I immediately get the error and redirect to
https://www.domain.com/wp-login.php?redirect_to=https%3A%2F%2Fdomain.com%2Fwp-admin%2F&reauth=1

Hello @codepantry,

I don’t think that posts are related to your issue. Could you try to set your domain as explain here?
https://docs.bitnami.com/aws/apps/wordpress/administration/configure-domain/

You would need to set:

define('WP_SITEURL', 'https://auXXX.com/');
define('WP_HOME', 'https://auXXX.com/');

If that does not work, maybe these posts can help (some of them are in Spanish, but you can translate them):
https://stackoverflow.com/questions/52945951/wordpress-always-redirects-to-wp-login-php/52946879
https://juanluismora.es/wordpress/error-en-login-de-wordpress-wp-login-phpredirect.html
https://ayudawp.com/loop-de-redirecciones-en-wp-login-con-reauth1-soluciones/

Regards

@davidg Can you edit this ticket at the very top and remove my domain name from it? Bitnami’s SEO is very strong. Is this possible?

I have executed the following

  • flushed my dns
  • cleared my cache
  • re-verified define ‘WP_HOME’ and ‘WP_SITEURL’ values
  • changed the wp cms security keys - https://api.wordpress.org/secret-key/1.1/salt/
  • deleted session tokens in user meta > session_tokens
  • reverted to the default wp cms theme and deleted all plugins
  • tested in incognito window and a different browser.
  • set max_execution_time = 300 seconds max_input_time = 300 seconds
  • restarted the instance ctlscript.sh restart
  • successfully tested nginx config file nginx -t
    The error remains.

A couple of strange things for my particular error.

  • turning on wp-debug bypasses this error but then impossible to diagnose the cause
  • removing redirect_to and all url variables bypasses this error

Because I disabled all plugins and theme such that only the default theme was active but the error remained, I think it is it is the forwarding with nginx and php-fpm that is causing this hence an nginx config related

Hello @codepantry,

Done

I can see you commented out these lines:


    # HTTP Server
#    server {
        # Port to listen on, can also be set in IP:PORT format
#        listen  80;
#        include  "/opt/bitnami/nginx/conf/bitnami/*.conf";

#        location /status {
#            stub_status on;
#            access_log   off;
#            allow 127.0.0.1;
#            deny all;
#        }
#    }

Could you uncomment them and restart NGINX?

If that does not work, could you please share the content of your NGINX logs with us?

tail -n 100 /opt/bitnami/nginx/logs/error.log 

Regards

Thanks, I turned that back on and was able to see this error
redirect_to=https%3A%2F%2Fdomain.com%2Fwp-admin%2F&reauth=1 HTTP/1.1", upstream: “fastcgi://unix:/opt/bitnami/php/var/run/www.sock:”, host: “domain.com"
/opt/bitnami/nginx/conf#

The solution is to
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

Thanks, I turned that back on and was able to see this error
redirect_to=https%3A%2F%2Fdomain.com%2Fwp-admin%2F&reauth=1 HTTP/1.1", upstream: “fastcgi://unix:/opt/bitnami/php/var/run/www.sock:”, host: “domain.com"
/opt/bitnami/nginx/conf#

The solution is per this links is to adjust he buffering configuration
https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_bind
https://www.cyberciti.biz/faq/nginx-upstream-sent-too-big-header-while-reading-response-header-from-upstream/
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

The above got it to work. Please confirm.

Hi @codepantry

I can see that wp-admin is redirecting is properly. I’m glad it worked.

Regards

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.