location ~* ^.+\.php$ {
more_set_headers "X-Frame-Options: SAMEORIGIN"; # Запрещаем фреймы на чужих сайтах
# more_set_headers "Cache-Control: max-age=0, no-cache, no-store, must-revalidate, no-transform"; # Запрещаем кэширование ответов
try_files $uri =404;
fastcgi_pass backend;
fastcgi_param TMP "%sprogdir%/userdata/temp";
fastcgi_param TMPDIR "%sprogdir%/userdata/temp";
fastcgi_param TEMP "%sprogdir%/userdata/temp";
include "%sprogdir%/modules/http/%httpdriver%/conf/fastcgi_params";
}
Этот вариант неправильно из-за того что одна и та же конфигурация для всех сайтов.
Стоит разместить сам файл конфигурации nginx в директории проекта.
Тогда изменения конфигурации 1 виртуального сервера не затронет остальные конфигурации.
server {
listen %ip%:%httpport%;
listen %ip%:%httpsport% ssl;
server_name testsite.ru;
index index.php;
charset utf-8;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
ssl_certificate "%sprogdir%/userdata/config/server.crt";
ssl_certificate_key "%sprogdir%/userdata/config/server.key";
# if ($request_method !~* ^(GET|HEAD|POST)$ ){return 403;}
location ~ /\. {deny all;}
location / {
root "F:\Server\OSPanel\domains\localhost\frontend";
try_files $uri $uri/ /index.php$is_args$args;
location ~ \.php$ {
try_files $uri =404;
# if (!-e $document_root$document_uri){return 404;}
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_buffers 4 64k;
fastcgi_connect_timeout 1s;
fastcgi_ignore_client_abort off;
fastcgi_next_upstream timeout;
fastcgi_read_timeout 5m;
fastcgi_send_timeout 5m;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param HTTPS $https;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $host;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param TMP "%sprogdir%/userdata/temp";
fastcgi_param TMPDIR "%sprogdir%/userdata/temp";
fastcgi_param TEMP "%sprogdir%/userdata/temp";
}
}
}
server {
listen %ip%:%httpport%;
listen %ip%:%httpsport% ssl;
server_name testsite.ru;
root "F:\Server\OSPanel\domains\localhost\megatest";
charset utf-8;
add_header Env admin;
#add_header "Access-Control-Allow-Origin" "http://localhost:3000";
#add_header "Access-Control-Allow-Headers" "Origin, X-Requested-With, Content-Type, Accept, Authorization";
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* ^.+\.php$ {
more_set_headers "X-Frame-Options: SAMEORIGIN"; # Запрещаем фреймы на чужих сайтах
# more_set_headers "Cache-Control: max-age=0, no-cache, no-store, must-revalidate, no-transform"; # Запрещаем кэширование ответов
try_files $uri =404;
fastcgi_pass backend;
fastcgi_param TMP "%sprogdir%/userdata/temp";
fastcgi_param TMPDIR "%sprogdir%/userdata/temp";
fastcgi_param TEMP "%sprogdir%/userdata/temp";
include "%sprogdir%/modules/http/%httpdriver%/conf/fastcgi_params";
}
}