In /etc/nginx/sites-available/yourconfig Below the server_name server { server_name mydomain.com www.mydomain.com; if ($scheme = "http") { return 301 https://$server_name$request_uri; } }