File size: 905 Bytes
deb090d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
server {
    listen 80;

    # Root directory for the React app
    root /usr/share/nginx/html;
    index index.html index.htm;

    # Handle client-side routing for React
    location / {
        try_files $uri /index.html;
    }

    # Proxy API requests to the backend service
    # Any request to http://<your-space-url>/api/...
    # will be forwarded to http://backend:8000/...
    location /api {
        proxy_pass http://backend:8000; # 'backend' is the service name in docker-compose.yml
        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;
    }

    # Optional: Improve performance with caching for static assets
    location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg)$ {
        expires 1y;
        add_header Cache-Control "public";
    }
}