Question

let's encrypt redirected you too many times using browser

Hi, I am trying to install SSL on my site and i followed https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04. However, I am not able to opt for only https option. Every time I select HTTPS redirect option the sites doesn’t load where browser says too many redirect. I have fiddle over an internet for few hours but no luck. Could some one please help me with this. I have paste my server block config. Thank you.

server { server_name www.drupalizenepal.com drupalizenepal.com; root /srv/www/drupalizenepald8/docroot;

error_log /srv/www/drupalizenepald8/logs/error.log; access_log /srv/www/drupalizenepald8/logs/access.log;

client_max_body_size 10M;

location = /favicon.ico { log_not_found off; access_log off; }

location = /robots.txt { allow all; log_not_found off; access_log off; }

location ~ ../..php$ { return 403; }

location / { index index.php;

This is cool because no php is touched for static content

try_files $uri $uri/ @rewrite;

}

location @rewrite {

Some modules enforce no slash (/) at the end of the URL

Else this rewrite block wouldn’t be needed (GlobalRedirect)

rewrite ^/(.*)$ /index.php?q=$1;

}

location ~ .php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; #NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini include fastcgi_params; fastcgi_read_timeout 300; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/run/php/php7.0-fpm.sock; }

Fighting with ImageCache? This little gem is amazing.

location ~ ^/sites/.*/files/styles/ { try_files $uri @rewrite; }

location ~* .(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; }

location ~* /(?:.+)/files/styles/adaptive/(?:.+)$ { if ( $http_cookie ~* “ais=(?<ais_cookie>[a-z0-9-_]+)” ) { rewrite ^/(.+)/files/styles/adaptive/(.+)$ /$1/files/styles/$ais_cookie/$2 last; } access_log off; add_header X-Header “AIS Generator 1.0”; set $nocache_details “Skip”; try_files $uri @drupal; } # managed by Certbot

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/drupalizenepal.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/drupalizenepal.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

} server { if ($host = www.drupalizenepal.com) { return 301 https://$host$request_uri; } # managed by Certbot

if ($host = drupalizenepal.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot

server_name www.drupalizenepal.com drupalizenepal.com;

listen 80;
return 404; # managed by Certbot

}


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Ryan Quinn
DigitalOcean Employee
DigitalOcean Employee badge
April 24, 2018
Accepted Answer

The most common way to find yourself with a redirect loop after setting up LetsEncrypt is if you are using a CMS system that does it’s own URL rewrites outside the nginx configuration. WordPress is a good example of this.

In WordPress when it is first set up a base URL setting is created using the domain or IP that you used when running the setup wizard. If you then create a redirect to force a different URL, WordPress will receive the request and redirect to what it is configured to know as the “Correct URL”.

If you’re running WordPress, check your wp-admin main site settings and ensure that the URL you are using there matches what your new redirect will send users to.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.