server { listen 80; server_name testdomain.com www.testdomain.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name testdomain.com www.testdomain.com; # SSL configuration ssl_certificate /etc/letsencrypt/live/testdomain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/testdomain.com/privkey.pem; # Improve HTTPS security (optional, but recommended) ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; root /home/www/testdomain.com; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }