server { listen 3000; server_name _; root /usr/share/nginx/html; index index.html; # Long cache for fingerprinted Next assets location /_next/static/ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # Proxy API calls to the Go service. # `flow` is the service name on the docker-compose network. location /api/ { proxy_pass http://flow:8090; 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; proxy_read_timeout 120s; } # Next static export uses trailingSlash=true; map directory paths to # their index.html. Try the requested URI, then the directory, then the # 404 page (Next's _not-found export). location / { try_files $uri $uri/ $uri.html $uri/index.html /index.html =404; } # Don't log the favicon nag location = /favicon.ico { log_not_found off; access_log off; } }