I just used certbot to install let’s encrypt on a ubuntu 16.04 server and Nginx. The install went fine and I was able to vertify the install using ssl labs website. When I edit the nginx conf file etc/nginx/sites-available/mysite and uncomment the redirect added by certboot in the botton of the file `
# Redirect non-https traffic to https
# if ($scheme != "https") {
# return 301 https://$host$request_uri;
# } # managed by Certbot
` the site starts redirection to itself in a loop.
My server block looks like this (server name changed):
`server {
listen 80;
#listen [::]:80; # Uncomment this line if you also want to enable IPv6 support
server_name example.com www.example.com *.example.com;
root /var/www/example;
access_log /var/log/nginx/example.access.log;
error_log /var/log/nginx/example.error.log;
server_tokens off;
index index.php; # Letting nginx know which files to try when requesting a folder
#index /example/index.php; # Letting nginx know which files to try when requesting a folder
location = /favicon.ico {
log_not_found off; #
access_log off; # Disable logging to prevent excessive log sizes
#################
} `
The redirect made by certbot is in the botton of the conf file, not insied the server block at thoe top of the file.