I want to redirect all my http traffic to redirect to https. I am using letsencrypt. I read online that return 301 https://$server_name$request_uri; would redirect all the traffic to my website over to https but instead it results in ERR_TOO_MANY_REDIRECTS.
Everything works fine without the above mention statement, but then I have to specifically specify https in the URL. Here's my /etc/nginx/sites-available/default file:
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; } } Where am I going wrong?
