server {
access_log off;
error_log /var/log/nginx/test.ru.error.log warn;
server_name test.ru www.test.ru;
charset UTF-8;
root /var/www/html/test.ru/public_html;
index index.php index.html index.htm;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_intercept_errors on;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/test.ru.crt;
ssl_trusted_certificate /etc/ssl/test.ru.crt;
ssl_certificate_key /etc/ssl/test.ru.key;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
resolver 127.0.0.1;
location /private {
auth_basic "Enter login & password!";
auth_basic_user_file /etc/nginx/conf.d/.htpasswd-tc;
}
}
server {
if ($host = www.test.ru) {
return 301 https://$host$request_uri;
}
if ($host = test.ru) {
return 301 https://$host$request_uri;
}
server_name test.ru www.test.ru;
listen 80;
return 404;
}