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;
errorlog /srv/www/drupalizenepald8/logs/error.log;
accesslog /srv/www/drupalizenepald8/logs/access.log;
clientmaxbody_size 10M;
location = /favicon.ico {
lognotfound off;
access_log off;
}
location = /robots.txt {
allow all;
lognotfound 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$ {
fastcgisplitpath_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;
lognotfound off;
}
location ~* /(?:.+)/files/styles/adaptive/(?:.+)$ {
if ( $httpcookie ~* “ais=(?<aiscookie>[a-z0-9-]+)” ) {
rewrite ^/(.+)/files/styles/adaptive/(.+)$ /$1/files/styles/$aiscookie/$2 last;
}
accesslog off;
addheader X-Header “AIS Generator 1.0”;
set $nocachedetails “Skip”;
tryfiles $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
}
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.
×