Spaces:
Running
Running
File size: 3,712 Bytes
5301c48 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
upstream backend {
server 127.0.0.1:8002;
}
upstream frontend {
server 127.0.0.1:3000;
}
server {
listen 7860;
server_name localhost;
# Handle Next.js Image Optimization API with direct serving fallback
location /_next/image {
# Extract the image URL from query parameters and redirect internally
set $image_path "";
if ($args ~ "url=([^&]+)") {
set $image_path $1;
}
# Remove URL encoding (basic cases)
if ($image_path ~ "^%2F(.*)") {
set $image_path /$1;
}
# Internal redirect to serve the image directly
if ($image_path != "") {
rewrite ^.*$ /public-images$image_path last;
}
return 404;
}
# Internal location to serve public images
location /public-images/ {
internal;
alias /app/web/public/;
expires 1y;
add_header Cache-Control "public, immutable";
}
# Serve Next.js static files directly
location /_next/static/ {
alias /app/web/.next/static/;
expires 1y;
add_header Cache-Control "public, immutable";
}
# Serve public files directly from root (logo, favicon, etc.)
location ~ ^/(starfish_logo\.png|nvidia\.png|microsoft_startups\.png|favicon\.ico|robots\.txt|sitemap\.xml)$ {
root /app/web/public;
expires 1y;
add_header Cache-Control "public";
}
# Serve amplify-ui.css and other public CSS files
location ~ ^/(amplify-ui\.css)$ {
root /app/web/public;
expires 1y;
add_header Cache-Control "public";
}
# Handle other public files with /public/ prefix
location /public/ {
alias /app/web/public/;
expires 1y;
add_header Cache-Control "public";
}
# Direct access to FastAPI docs (bypass Next.js)
location /backend-docs {
proxy_pass http://backend/docs;
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-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
# Direct access to FastAPI OpenAPI schema (bypass Next.js)
location /backend-openapi.json {
proxy_pass http://backend/openapi.json;
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-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
# Let Next.js handle all other routes
location / {
proxy_pass http://frontend;
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-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_buffering off;
proxy_redirect off;
}
}
} |