1

everything working fine, but when I enable secure admin (ssl) it gives redirect loop issue. I am not able to use admin pannel also cross origin issue for front ens static content.

I am using ssl over nginx + varnish.

I tried so many things (even may stackexchange answers) but no luck. can someone help me to tackle this issue.

Nginx configuration (magento2 nginx sample config included).

upstream fastcgi_backend {
  server   unix:/run/php/php7.0-fpm.sock;
}
  server {
    server_name mydomain.com www.mydomain.com 1xx.xx.xx.xxx; #private Ip included
    listen 8080;
    set $MAGE_ROOT /var/www/html/mysiteconf;
    set $MAGE_MODE developer; # or production

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
  #mujassam
        #fastcgi_param HTTPS on;
    include /var/www/html/mydomain/nginx.conf.sample;
  }
server {

      # listen 443 ssl;

      #added by mujassam
      listen 443 ssl http2; #m ## listen for ipv4; this line is default and
      implied listen [::]:443 ssl http2;
      server_name www.mydomain.com;

      ssl_certificate /etc/ssl/certs/www_mydomain_com.crt;
      ssl_certificate_key /etc/ssl/private/www_mydomain_com.key;
      ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;
      #mujassam
       #  fastcgi_param   HTTPS               on;
       # fastcgi_param   HTTP_SCHEME         https;
       ssl_prefer_server_ciphers on;
      ###
      ssl_ciphers               'AES128+EECDH:AES128+EDH:!aNULL';
      ssl_session_cache    shared:SSL:10m;
      ssl_session_timeout 24h;
      keepalive_timeout 300s;
location / {
    proxy_pass http://127.0.0.1:80;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Ssl-Offloaded "1";
    proxy_set_header      X-Forwarded-Proto https;
    proxy_set_header      X-Forwarded-Port 443;
    #mujassam added
    proxy_set_header X-Forwarded-Ssl on;
    #proxy_hide_header X-Varnish;
    #proxy_hide_header Via;
    proxy_set_header X-Forwarded-Proto $scheme;
 }
}

Hope Some body can help.

3 Answers 3

0

I was facing the same problem and someone tells me to set the base url with https.

Set to NO for Use Secure URLs on Storefront AND Use Secure URLs in Admin.

If you can't access to admin panel, you could do this with :

php bin/magento setup:store-config:set --base-url="https://yourdomain.com"

php bin/magento cache:flush

Hope it helps

0

Issue: ERR_TOO_MANY_REDIRECTS - redirected you too many times

This issue is related cookie domain name.

For ex: if you already installed Magento 2 in www.example.com, and now you change magento base path to sub domain path like www.subdomain.example.com means, then you need to update your cookie domain entry inside of core_config_data table. You cannot access magento 2 backend so you can use following query to check record exist else use insert query.

SELECT * FROM  `core_config_data` WHERE  `path` REGEXP  'cookie_domain'

if record exit then update subdomain.example.com to the value column.

else

INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`, `value`) VALUES ('default', 0, 'web/cookie/cookie_domain', 'subdomain.example.com');

Then flush cache using command php bin/magento cache:flush

Refresh magento 2 admin, now you can access admin. try this. thanks.

1
  • Thanks for providing a helpful answer. Commented Mar 15, 2019 at 9:34
0

Putting this here to hopefully save others some time.

I had everything configured correctly in regards to Varnish but was setting up a new environment that also utilized Redis for session and backend cache.

Double check the projects var/log derectory for redis errors. In my case it was unable to connect to the redis server and somehow that routed the traffic back to varnish and created a redirect loop.

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.