ERR_TOO_MANY_REDIRECTS status 302, how to configure NGINX locations to work with AWS ALB?

The problem happens because of the way AWS ALB works, or at least the way mine is setup (which seems to be quiet common practice to be fair), the Loadbalancer listens on HTTPS:443 and forwards to the target HTTP:80. The problem above err-too-many-redirects is related to an endless loop created by the target application. The user requests /wp-admin and an endless loop of forwards keeps going without ever resolving unless we force WordPress administration to use SSL mode, which is possible by setting the parameter force ssl admin in the wp-config.php:

define('FORCE_SSL_ADMIN', true);

I found out about this after trying the PHP reserved variable for server https:

$_SERVER['HTTPS'] = 'on'

Both should help fix the problem, I say “help”, because you may still find mixed content warning messages, etc, and some browsers may actually prevent the content (img, css, etc) from loading or even prevent rendering your application service. So, beware of any bad protocol smells (HTTP vs HTTPS) in your WordPress database, etc – that’s out of the scope for the case I exposed initially, that is the 302, but I hope it’s helpful and takes you to the right direction if that happens to you.

The issue above is quite common given the AWS architecture that they have released a tutorial about a similar use case ( https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#redirect-actions ).