File: /var/www/cod67/data/www/cod67.ru/public_html/nginx.conf
server {
listen 80;
listen 443 ssl http2;
server_name ваш-домен.рф www.ваш-домен.рф;
# SSL настройки (если используете HTTPS)
ssl_certificate /path/to/certificate.crt;
ssl_certificate_key /path/to/private.key;
# Перенаправление с www на без www
if ($host ~* ^www\.(.*)$) {
return 301 $scheme://$1$request_uri;
}
# Перенаправление с HTTP на HTTPS (если используете SSL)
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
# Корневая директория
root /var/www/your-site;
index index.php index.html index.htm;
# Обработка статических файлов
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# Обработка PHP файлов
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Важно для WordPress
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SERVER_NAME $host;
# Безопасность
fastcgi_param HTTPS on;
fastcgi_hide_header X-Powered-By;
}
# Основной location для WordPress
location / {
try_files $uri $uri/ /index.php?$args;
}
# Защита от ботов и сканеров
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~ /(wp-config\.php|readme\.html|license\.txt) {
deny all;
access_log off;
log_not_found off;
}
}