app/nginx/nginx.conf

54 lines
1.6 KiB
Nginx Configuration File
Raw Permalink Normal View History

2025-04-18 08:30:00 +02:00
server {
listen 80;
server_name localhost;
# === FRONTEND ===
location / {
proxy_pass http://frontend:3000;
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;
# WebSocket support (optional but good for Next.js dev tools etc.)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# === BACKEND API ===
location /api/ {
proxy_pass http://backend:80;
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;
}
# === Sanctum (Laravel token auth) ===
location /sanctum/ {
proxy_pass http://backend:80;
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;
}
# === Client-side routing fallback (Next.js or SPA mode) ===
error_page 404 /index.html;
location = /index.html {
proxy_pass http://frontend:3000/index.html;
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;
}
}