I have install magento2 in AWS ec2 behind a load balancer . But when i try to access to login admin page i have error too many redirection

The problem is all solution i have fine not work .

I try all of this

php bin/magento config:set web/secure/use_in_adminhtml 1
php bin/magento config:set web/secure/use_in_frontend 1
php bin/magento config:set web/cookie/cookie_httponly 0

i try to put web/unsecure/base_url with a https

web/unsecure/base_url = https://example.com

i try too remove and add my domain name in this variable

web/cookie/cookie_domain NULL
web/cookie/cookie_domain https://example.com

i try to put this in my .htaccess

SetEnv X-Forwarded-Proto=https
SetEnv HTTPS=on


SetEnvIf X-Forwarded-Proto https HTTPS=on

i try too add on the index.php


but i don't have mage::run

my index.php finish with this

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);

my core_config_data look like this


2 Answers 2


Before using setEnv for SSL variables, you must first initialize them using SLOptions StdEnvVars.

After that you can define the variables referring to ssl:

<IfModule mod_ssl.c>
  SSLOptions StdEnvVars
  SetEnv X-Forwarded-Proto "https"
  SetEnv HTTPS "on"

I have found an answer that may solve your issue: https://magento.stackexchange.com/a/38251

Add these lines to the end of your .htaccess and it should be fine:

Detect the Load-Balancer-Header and set the header magento expects

SetEnvIf X-Forwarded-Proto https HTTPS=on

Could you try it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.