diff --git a/Dockerfile b/Dockerfile index 0d1ac6c..5bcac21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,10 +22,7 @@ FROM nginx:stable-alpine AS runner # Copy build output COPY --from=builder /app/build /usr/share/nginx/html -# Optionnel : config nginx simple (si tu veux un fallback pour SPA) -# Crée un fichier nginx.conf local et COPY-le ici si tu veux une config spécifique. -# Exemple basique pour SPA (fallback to index.html) -# COPY nginx-spa.conf /etc/nginx/conf.d/nginx-spa.conf +COPY nginx-spa.conf /etc/nginx/conf.d/nginx-spa.conf # Expose port 80 (Caddy fera reverse proxy) EXPOSE 80 diff --git a/nginx-spa.conf b/nginx-spa.conf new file mode 100644 index 0000000..811ca97 --- /dev/null +++ b/nginx-spa.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + # Proxy API to backend container + location /api/ { + proxy_pass http://poster-picker-backend-1:5000/api/; + 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; + } + + # SPA fallback + location / { + try_files $uri $uri/ /index.html; + } +}