change nginx.conf
This commit is contained in:
@@ -18,7 +18,7 @@ server {
|
||||
listen 443 ssl http2;
|
||||
server_name www.ntspi.ru;
|
||||
|
||||
# SSL-конфигурация
|
||||
# --- SSL Настройки ---
|
||||
ssl_certificate /etc/letsencrypt/live/www.ntspi.ru/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/www.ntspi.ru/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/www.ntspi.ru/chain.pem;
|
||||
@@ -33,7 +33,7 @@ server {
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# Сжатие
|
||||
# --- Сжатие ---
|
||||
gzip on;
|
||||
gzip_disable "msie6";
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
||||
@@ -46,63 +46,72 @@ server {
|
||||
client_max_body_size 200M;
|
||||
large_client_header_buffers 4 128k;
|
||||
|
||||
# --- КОРНЕВАЯ ПАПКА LARAVEL ---
|
||||
# Важно: это путь ВНУТРИ контейнера Nginx и PHP
|
||||
root /var/www/public;
|
||||
|
||||
# Security headers
|
||||
# --- Заголовки безопасности ---
|
||||
add_header X-Frame-Options "SAMEORIGIN";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
|
||||
|
||||
# Основной вход в приложение
|
||||
location / {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
try_files $uri /index.php?$args;
|
||||
}
|
||||
index index.php index.html;
|
||||
|
||||
# =========================================================================
|
||||
# Настройки для VIKON CORE (Исправление ошибки 404)
|
||||
# БЛОК VIKON CORE
|
||||
# Используем ^~ чтобы этот блок имел приоритет над регулярными выражениями
|
||||
# =========================================================================
|
||||
location ^~ /vikon_core/ {
|
||||
root /var/www/public;
|
||||
# Здесь мы НЕ используем try_files $uri /index.php, чтобы Laravel не перехватывал запросы
|
||||
|
||||
# Обработка PHP внутри vikon_core
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass app:9000;
|
||||
include fastcgi_params;
|
||||
|
||||
# Поскольку vikon_core лежит в public, путь формируется корректно:
|
||||
# /var/www/public + /vikon_core/script.php
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param HTTPS On;
|
||||
fastcgi_buffers 16 16k;
|
||||
fastcgi_buffer_size 32k;
|
||||
}
|
||||
}
|
||||
|
||||
# Статические разделы SVEDEN и ABITUR
|
||||
# =========================================================================
|
||||
# Статика для SVEDEN и ABITUR (если они лежат в public, alias не обязателен,
|
||||
# но оставим для совместимости с вашей текущей логикой)
|
||||
# =========================================================================
|
||||
location /sveden/ {
|
||||
alias /var/www/public/sveden/;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /sveden/index.html;
|
||||
expires epoch;
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
|
||||
}
|
||||
|
||||
location = /sveden {
|
||||
return 301 /sveden/;
|
||||
}
|
||||
|
||||
location /abitur/ {
|
||||
alias /var/www/public/abitur/;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /abitur/index.html;
|
||||
expires epoch;
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
|
||||
}
|
||||
|
||||
location = /abitur {
|
||||
return 301 /abitur/;
|
||||
# Редиректы без слеша
|
||||
location = /sveden { return 301 /sveden/; }
|
||||
location = /abitur { return 301 /abitur/; }
|
||||
|
||||
# =========================================================================
|
||||
# ОСНОВНОЙ БЛОК LARAVEL
|
||||
# =========================================================================
|
||||
location / {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# Общий обработчик PHP для остального сайта
|
||||
# Обработка PHP для всего остального (Laravel index.php)
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
@@ -117,12 +126,14 @@ server {
|
||||
fastcgi_param HTTPS On;
|
||||
}
|
||||
|
||||
# Запрет доступа к скрытым файлам
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
# Запрет доступа к служебным файлам
|
||||
location ~ ^/(upload|storage|images|docs|files)/.*\.php$ { deny all; return 404; }
|
||||
location ~ ^/storage/app/public/upload/iblock/.*\.php$ { deny all; return 404; }
|
||||
location ~ ^/vendor/.*\.php$ { deny all; return 404; }
|
||||
location ~ /\.ht { deny all; }
|
||||
location ~ /\.(?!well-known).* { deny all; }
|
||||
|
||||
# Блок для обновления Let's Encrypt
|
||||
# Certbot
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
allow all;
|
||||
|
||||
Reference in New Issue
Block a user