From 059f3e2e33ec5790efc15e068d7876241746aa21 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Tue, 4 Nov 2025 22:59:42 +0100 Subject: [PATCH] Added the nginx conf for dev2.4nkweb.com --- nginx.prod.conf | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 nginx.prod.conf diff --git a/nginx.prod.conf b/nginx.prod.conf new file mode 100644 index 0000000..88b55b4 --- /dev/null +++ b/nginx.prod.conf @@ -0,0 +1,79 @@ +# --- 1. REDIRECTION HTTP VERS HTTPS --- +server { + listen 80; + server_name dev2.4nkweb.com; + return 301 https://$host$request_uri; +} + +# --- 2. CONFIGURATION HTTPS PRINCIPALE --- +server { + listen 443 ssl; + server_name dev2.4nkweb.com; + + # Chemins des certificats SSL + ssl_certificate /etc/letsencrypt/live/dev2.4nkweb.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/dev2.4nkweb.com/privkey.pem; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_prefer_server_ciphers on; + ssl_ciphers HIGH:!aNULL:!MD5; + + # --- LOCATION POUR VITE (Front-end + HMR WebSocket) --- + location / { + proxy_pass http://localhost:3003; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + } + + # --- LOCATION POUR L'AUTRE WEBSOCKET (port 8090) --- + location /ws/ { + proxy_pass http://localhost:8090; + 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_set_header X-NginX-Proxy true; + proxy_read_timeout 86400; + } + + # --- LOCATION POUR SDK_STORAGE (port 8081) --- + location /storage/ { + # Gestion du préflight CORS + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With' always; + add_header 'Access-Control-Max-Age' 86400; + add_header 'Content-Length' 0; + add_header 'Content-Type' 'text/plain'; + return 204; + } + # Headers CORS pour les requêtes réelles + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With' always; + rewrite ^/storage(/.*)$ $1 break; + proxy_pass http://localhost:8081; + proxy_http_version 1.1; + proxy_set_header Host $host; + } + + # --- LOCATION POUR TON API (port 8091) --- + location /api/ { + proxy_pass http://localhost:8091; + proxy_http_version 1.1; + 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; + + # CORS headers + add_header Access-Control-Allow-Origin "*" always; + add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE" always; + add_header Access-Control-Allow-Headers "Authorization,Content-Type,Accept,X-Requested-With" always; + } +} \ No newline at end of file