Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
listen 80; ## listen for ipv4
server_name test.pro www.test.pro;
set $main_host 'test.pro';
#Делаем, чтобы сайт не открывался по IP
if ($http_host ~ "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") {
return 444;
}
if ($host != $main_host) {
rewrite ^(.*)$ http://$main_host$1 permanent;
break;
}
root /var/www/$main_host/www;
index index.php;
## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
if ($http_user_agent ~* "WordPress") {
return 444;
}
location / {
try_files $uri $uri/ /index.php?$args;
rewrite ^/(.+?)/(.+?)$ /cp.php?name=$1&nick=$2 last;
}
location ^~ /.well-known/acme-challenge {
default_type "text/plain";
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9056;
include /etc/nginx/conf/fastcgi_params.conf;
fastcgi_param SCRIPT_FILENAME /var/www/$main_host/www$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /var/www/$main_host/www;
fastcgi_param PHP_ADMIN_VALUE upload_tmp_dir=/var/www/$main_host/tmp/upload;
fastcgi_param PHP_ADMIN_VALUE session.save_path=/var/www/$main_host/tmp/sessions;
}
location = /favicon.ico {
try_files /favicon.ico @favicon_empty;
expires 7d;
access_log off;
log_not_found off;
}
location @favicon_empty {
empty_gif;
expires 7d;
access_log off;
log_not_found off;
}
location ~* ^.+\.(ico|htm|html|txt|jpg|png|gif|css|js|ttf|woff|woff2|svg)$ {
access_log off;
autoindex off;
expires 30d;
add_header Cache-Control 'public';
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}