From eaf769177f44b5f279ab047b4e6146bb61389a2e Mon Sep 17 00:00:00 2001 From: Aleksandr Zaitsev Date: Fri, 19 Jul 2024 15:15:54 +0300 Subject: [PATCH] add simple nginx config for php application --- nginx-site.conf | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 nginx-site.conf diff --git a/nginx-site.conf b/nginx-site.conf new file mode 100644 index 0000000..cafd432 --- /dev/null +++ b/nginx-site.conf @@ -0,0 +1,38 @@ +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; + } +} \ No newline at end of file