server {
#listen [::]:80;
server_name domen.ru;
root /var/test/;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.php index.html index.hml;
location / {
try_files $uri $uri/ /index.html;
}
location /v3/ {
...
}
location ^~ /common/ {
...
}
location ~* /templateimg/.*\.(jpg|jpeg|gif|png|ico)$ {
if ($http_origin ~* "^ ...REG... $") {
add_header 'Access-Control-Allow-Origin' '$http_origin';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken';
add_header 'Access-Control-Allow-Methods' 'GET';
}
alias /var/_img/;
rewrite /var/_img/$1 last;
}
# Разрешить использовать шрифты из домена
location ~* \.(eot|ttf|woff|woff2|svg)$ {
access_log off;
add_header Access-Control-Allow-Origin *;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location ~ /\.ht {
deny all;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_keep_conn on;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
error_page 404 /404.html;
error_page 403 /403.html;
error_page 405 =200 $uri;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}