From e92e8a912ca6bc7cd088c2035673fd6cadfc319c Mon Sep 17 00:00:00 2001 From: F4ilji Date: Sat, 14 Jun 2025 23:09:35 +0500 Subject: [PATCH] adding new configuration for http testing --- .gitignore | 4 +- _docker/nginx/test/conf.d/nginx.conf | 76 +++++++++++++++++++++ app/Providers/ForceHttpsServiceProvider.php | 2 +- docker-compose.yml | 2 - resources/views/app.blade.php | 5 +- 5 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 _docker/nginx/test/conf.d/nginx.conf diff --git a/.gitignore b/.gitignore index 11ab86b..3542715 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ deploy.sh _deploy /public/build /public/abitur -/public/sveden \ No newline at end of file +/public/sveden +dump.sql +.idea \ No newline at end of file diff --git a/_docker/nginx/test/conf.d/nginx.conf b/_docker/nginx/test/conf.d/nginx.conf new file mode 100644 index 0000000..ea07586 --- /dev/null +++ b/_docker/nginx/test/conf.d/nginx.conf @@ -0,0 +1,76 @@ +server { + + gzip on; + gzip_disable "msie6"; # Отключение для IE6 (устаревший браузер) + + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml; + + gzip_min_length 1024; + + gzip_comp_level 6; + + gzip_buffers 16 8k; + + gzip_proxied any; + + gzip_vary on; + + client_max_body_size 200M; # Максимальный размер тела запроса + large_client_header_buffers 4 128k; # Размеры буферов для заголовков + + root /var/www/public; + + location / { + add_header Access-Control-Allow-Origin *; # Заголовок для CORS + try_files $uri /index.php?$args; # Обработка запросов + } + + 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 ~ \.php$ { + try_files $uri =404; # Если файл не найден, возвращаем 404 + fastcgi_split_path_info ^(.+\.php)(/.+)$; # Разделение пути + fastcgi_pass app:9000; # Указываем сервер PHP-FPM + fastcgi_index index.php; # Индексный файл + include fastcgi_params; # Включаем параметры FastCGI + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # Путь к скрипту + fastcgi_param PATH_INFO $fastcgi_path_info; # Информация о пути + fastcgi_buffers 16 16k; # Увеличение буферов FastCGI + fastcgi_buffer_size 32k; # Размер буфера FastCGI + } + + # Защита от доступа к конфиденциальным файлам + location ~ /\.ht { + deny all; # Запрет доступа к файлам .htaccess + } + + # Настройки кэширования для статических файлов + location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|otf)$ { + expires 30d; # Кэширование на 30 дней + add_header Cache-Control "public, no-transform"; # Заголовок кэширования + } + + +} diff --git a/app/Providers/ForceHttpsServiceProvider.php b/app/Providers/ForceHttpsServiceProvider.php index ae20cc1..97b9f9b 100644 --- a/app/Providers/ForceHttpsServiceProvider.php +++ b/app/Providers/ForceHttpsServiceProvider.php @@ -21,7 +21,7 @@ class ForceHttpsServiceProvider extends ServiceProvider */ public function boot(): void { - if ($this->app->environment('production')) { + if (env('NGINX_ENV') === 'prod') { URL::forceScheme('https'); } } diff --git a/docker-compose.yml b/docker-compose.yml index db6f667..00834e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - services: webserver: image: nginx:1.27.2 diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index fda2d3e..ea9bb96 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -3,8 +3,9 @@ - - + @if (env('NGINX_ENV') === 'prod') + + @endif {{-- {{ config('app.name', 'Laravel') }}--}}