42 lines
1.1 KiB
Nginx Configuration File
42 lines
1.1 KiB
Nginx Configuration File
worker_processes 1;
|
|
events { worker_connections 1024; }
|
|
http {
|
|
include mime.types;
|
|
default_type application/octet-stream;
|
|
sendfile on;
|
|
keepalive_timeout 65;
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Proxy API requests to backend service
|
|
# Frontend calls /api/recipes, nginx removes /api prefix and forwards to backend:8000/recipes
|
|
location /api/ {
|
|
proxy_pass http://backend:8000/;
|
|
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;
|
|
}
|
|
|
|
# Serve static files and fallback to index.html for SPA
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# Optional caching for static assets
|
|
location ~* \.(?:css|js|svg|png|jpg|jpeg|gif|ico)$ {
|
|
try_files $uri =404;
|
|
expires 7d;
|
|
add_header Cache-Control "public";
|
|
}
|
|
}
|
|
}
|