cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.2.2 with Varnish 4.1.9 and apache 2.4 has ssl redirect loop error

Magento 2.2.2 with Varnish 4.1.9 and apache 2.4 has ssl redirect loop error

We hope someone can point us to a new direction as we're at our wits end on this.
We installed Magento 2.2.2 CE when it first came out and hired a system engineer to set up Varnish for the server to work with Magento. Once Varnish starts, all https pages has an redirect loop error.

 

Since then, we have been trying to fix this issue without any solutions.(including hiring Magento certified people to take a look). The person who originally set up the Varnish has look into the matter and said that the settings for Vanish are correct and that the issue must be on Magento settings.


We've tried everything we've seen suggested online.
adding SetEnvIf X-Forwarded-Proto "https" HTTPS=on to .htaccess

trying all possible combination of settings for web/secure/use_in_frontend, web/secure/use_in_adminhtml, web/secure/enable_hsts, web/cookie/cookie_domain(between null and actual web url), web/secure/enable_upgrade_insecure and adding https to web/unsecure/base_url

We've also tried all possible combination of settings along with adding the SetEnvIf code.
We've cleared cache and cookie and tried different browser on every test attempt.

 

The only time we saw any change in our testing result was turning "Auto-redirect to Base URL" to No. With that setting and Varnish being on, https will work for the frontend but going to the custom admin url results in a 404 not found error.

 

We've been at this for so long that 2.2.3 is now out and we've not gain much on this issue. Any suggestions or insight is greatly welcomed.

5 REPLIES 5

Re: Magento 2.2.2 with Varnish 4.1.9 and apache 2.4 has ssl redirect loop error

Hello @iKitkat
Few things to you can consider checking.
1. Base url configuration in database, sometimes those are 2 times (cause of table prefix) when you search "web" in database. So please check that base url. Is correctly configured with https.
2. Please see if you have enabled use secure url yes for both frontend and backend.
3. Upload default .htaccess file of Magento and check
Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now

Re: Magento 2.2.2 with Varnish 4.1.9 and apache 2.4 has ssl redirect loop error

Thanks for taking the time to reply and help.

Unfortunately your suggestion did not solve our issue.

We double checked again for all "web" in database and it is correct with https and both use secure url for frontend and backend is yes.
We uploaded the default .htaccess file from Magento and retested but issue is still the same.


Re: Magento 2.2.2 with Varnish 4.1.9 and apache 2.4 has ssl redirect loop error

I had the same issue and solved this by adding the following to my Apache virtualhost for https:

<VirtualHost *:443>
## line below is the addition
RequestHeader set X-Forwarded-Proto "https"

[.... rest of vhost stuff goes here ....]
</VirtualHost>

Then restart Apache. If you get an error that "RequestHeader" command is not recognized, then you need to add the headers module to Apache2:

sudo a2enmod headers

restart Apache and clear your M2 cache and it should be working perfectly.

 

I hope this can help someone. I've wasted hours on this same issue today...

 

Re: Magento 2.2.2 with Varnish 4.1.9 and apache 2.4 has ssl redirect loop error

please set: web/secure/use_in_frontend and web/secure/use_in_adminhtml to 0

Please read here for more detail:
https://mrvts.wordpress.com/2018/12/17/magento-2-nginx-varnish-full-page-cache-backend-admin-redirec...

Re: Magento 2.2.2 with Varnish 4.1.9 and apache 2.4 has ssl redirect loop error

Hi, did you manage to fix that ? I'm trying to fix that for few months now with no luck.