diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..899309f --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +VITE_API_URL=https://russcult.anibilag.ru +VITE_APP_ENV=production diff --git a/.nginx/nginx.conf b/.nginx/nginx.conf index 90143f1..50620a1 100644 --- a/.nginx/nginx.conf +++ b/.nginx/nginx.conf @@ -1,22 +1,13 @@ server { - listen 80 default_server; - listen [::]:80 default_server; + listen 80 default_server; + listen [::]:80 default_server; - root /var/www/dist; - index index.html; + root /var/www/dist; + index index.html; - server_name russcult.anibilag.ru; - - location / { - try_files $uri /index.html; - } - - location /api/ { - proxy_pass http://192.168.1.67:5000; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - } + server_name russcult.anibilag.ru; + # Gzip compression gzip on; gzip_vary on; @@ -26,5 +17,32 @@ server { gzip_http_version 1.1; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + location / { + try_files $uri /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + location /api/ { + proxy_pass http://192.168.1.67:5000/api/; # 👈 сохраняем /api/ в пути + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_cache_bypass $http_upgrade; + } + error_page 404 /index.html; } diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..b82ae36 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# deploy.sh + +# Build the application +npm run build + +# Backup current deployment +sudo cp -r /var/www/dist /var/www/dist.backup.$(date +%Y%m%d_%H%M%S) + +# Deploy new build +sudo rm -rf /var/www/dist/* +sudo cp -r dist/* /var/www/dist/ + +# Set proper permissions +sudo chown -R www-data:www-data /var/www/dist +sudo chmod -R 755 /var/www/dist + +# Test nginx config and reload +sudo nginx -t && sudo systemctl reload nginx + +echo "Deployment completed successfully!" \ No newline at end of file diff --git a/src/pages/HomePage.tsx b/src/pages/HomePage.tsx index 814d227..2f1631e 100644 --- a/src/pages/HomePage.tsx +++ b/src/pages/HomePage.tsx @@ -12,8 +12,6 @@ export function HomePage() { const categoryId = searchParams.get('category'); const backgroundImage= BackgroundImages[Number(categoryId)]; - console.log(categoryId) - const getHeroTitle = () => { if (categoryId) { return {