From 734cc478e0e0b6bddfc47b15b74ef9580b04c748 Mon Sep 17 00:00:00 2001 From: MoonTestUse1 Date: Fri, 27 Dec 2024 05:52:25 +0600 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D0=B8=D0=BD=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20=D0=B4=D0=BE=D0=BA=D0=B5=D1=80?= =?UTF-8?q?=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/nginx/conf.d/default.conf | 71 +++++++++++++------------------- frontend/vite.config.ts | 20 ++++----- 2 files changed, 37 insertions(+), 54 deletions(-) diff --git a/docker/nginx/conf.d/default.conf b/docker/nginx/conf.d/default.conf index f628bd8..b86c1a1 100644 --- a/docker/nginx/conf.d/default.conf +++ b/docker/nginx/conf.d/default.conf @@ -1,48 +1,6 @@ -upstream backend_upstream { - server support-backend:8000; -} - server { - listen 80 default_server; + listen 80; server_name itformhelp.ru www.itformhelp.ru; - - root /usr/share/nginx/html; - index index.html; - - # Logging - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - # SPA routes - location / { - try_files $uri $uri/ /index.html; - add_header Cache-Control "no-store, no-cache, must-revalidate"; - } - - # API proxy - location /api/ { - proxy_pass http://backend_upstream; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - 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; - } -} - -# Редирект с IP на домен -server { - listen 80; - server_name 185.139.70.62; - return 301 http://itformhelp.ru$request_uri; -} - -server { - listen 80; - server_name localhost; location / { proxy_pass http://frontend:5173; @@ -51,11 +9,38 @@ server { proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; + + # WebSocket headers + 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; + + # WebSocket timeouts + proxy_read_timeout 86400; + proxy_send_timeout 86400; } location /api { proxy_pass http://backend:8000; 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; } + + # WebSocket HMR endpoint + location /_hmr { + proxy_pass http://frontend:5173; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + } +} + +# Redirect from IP to domain +server { + listen 80; + server_name 185.139.70.62; + return 301 http://itformhelp.ru$request_uri; } \ No newline at end of file diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 972c4b0..d658206 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,20 +1,18 @@ import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; -import { fileURLToPath, URL } from 'url'; export default defineConfig({ plugins: [vue()], - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)) - } - }, server: { - proxy: { - '/api': { - target: 'http://localhost:8000', - changeOrigin: true - } + host: true, + port: 5173, + watch: { + usePolling: true + }, + hmr: { + host: 'itformhelp.ru', + protocol: 'http', + clientPort: 80 } } }); \ No newline at end of file