I have a big problem with one magento installation. It is a Magento Version running on apache with php5-fpm, a Varnish cache in front and nginx as ssl reverse proxy.

If I open any URL using https, magento redirects to http://shopurl/index.php/ This then redirects to Location:/ I switched Web server rewrites and rediect to startpage off in the settings, no change. I created a dbg.php

echo "\n\n\ngetenv('HTTPS'): ";

The result is: this

You can see, that $_SERVER['HTTPS'] is set.

I don't know where else I can look to find the problem. For now, I changed the secure url to http://, because users where not able to login or purchase. But this can't be permanent.

Any Ideas how I can find out what is wrong?

If I activate proxy_redirect http:// $scheme://; in nginx, so it changes redirects to http:// to https://, a redirection loop endlessly redirecting to https://domain/index.php/ is the result.

The apache rewrite log for https://domain/test shows: - - [06/Feb/2014:12:20:14 +0000] [domain/sid#7f6236faac58][rid#7f61439ff0a0/initial] (2) [perdir /var/www/magento/] rewrite 'test' -> 'index.php'

So it seems that the redirect happens inside the magento PHP code...

4 Answers 4


try to paste this in your index.php

    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;


$_SERVER['HTTPS'] = 'on';

if i understand you right. or your nginx config is wrong.

  • 1
    amazing answer sir!
    – huzefam
    Commented Jul 24, 2017 at 10:33

Had exactly the same issue, but on Nginx. Resolved by adding the following into the nginx domain .conf file.

fastcgi_param HTTPS on;


Go to System -> Configuration -> Web -> Secure

Check if "Base Link URL" is set with "https".

Check that "Use Secure URLs in Frontend" is set to Yes.

  • Base link url has http and Use secure urls in frontent is Yes
    – Josef
    Commented Feb 7, 2014 at 7:37
  • I you want your site working with https you should define "Base Link URL" in System -> Configuration -> Web -> Secure with "https", otherwise it will redirect you to "http". Commented Feb 7, 2014 at 11:49
  • no, if I do that, I get an infinite redirection loop!
    – Josef
    Commented Feb 7, 2014 at 15:36

Using Database:

  • Open core_config_data table in your database.
  • Search for web/secure/offloader_header
  • Change its value to HTTP_X_FORWARDED_PROTO
  • Save and flush the cache.

If admin is working:

  • Open Stores > Settings > Configurations > General > Web
  • Open Tab Base URLs (Secure)
  • Update the value of Offloader header to HTTP_X_FORWARDED_PROTO

Try using HTTP_X_FORWARDED_PROTO if it does not work then use SSL_OFFLOADED

Your Answer

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

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