title: ERR_TOO_MANY_REDIRECTS with nginx
body: <p>I want to redirect all my <code>http</code> traffic to redirect to <code>https</code>. I am using <code>letsencrypt</code>. I read online that <code>return 301 https://$server_name$request_uri;</code> would redirect all the traffic to my website over to <code>https</code> but instead it results in <code>ERR_TOO_MANY_REDIRECTS</code>.</p>
  
  <p>Everything works fine without the above mention statement, but then I have to specifically specify <code>https</code> in the URL. Here's my <code>/etc/nginx/sites-available/default</code> file:</p>
  
  <pre><code>server {
          listen 80 default_server;
          listen 443 ssl default_server;
  
          ssl_certificate /etc/letsencrypt/live/mywebsite.me/fullchain.pem;
          ssl_certificate_key /etc/letsencrypt/live/mywebsite.me/privkey.pem;
  
          root /home/website/mywebsite/public;
  
          index index.html index.htm index.php;
  
          server_name mywebsite.me www.mywebsite.me;
  
          return 301 https://$server_name$request_uri;
  
          location / {
                  try_files $uri $uri/ /index.php$is_args$args;
          }
  
          location ~ \.php$ {
                  include snippets/fastcgi-php.conf;
                  fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
          }
  }
  </code></pre>
  
  <p>Where am I going wrong?</p>