From 122b4ce326197db4c27013ad04ac736647369062 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Jan 2026 14:20:41 +0000 Subject: [PATCH] Update nginx config and add Caddy2 support - Fixed nginx.conf to proxy all API routes (/patches, /generate, /health, /docs) - Changed frontend port to 3080 in docker-compose.yml - Added Caddyfile for Caddy2 reverse proxy configuration - Supports both FQDN and IP:port configurations --- Caddyfile | 54 +++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- frontend/nginx.conf | 32 ++++++++++++++++++++++++++- 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 Caddyfile diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..a4f50fb --- /dev/null +++ b/Caddyfile @@ -0,0 +1,54 @@ +# Caddy 2 Configuration for AI Photo Edit + +# Replace with your actual domain +ai-photo-edit.yourdomain.com { + # Frontend - serves the React app + reverse_proxy localhost:3080 + + # API routes - proxy to backend + handle /projects* { + reverse_proxy localhost:8000 + } + + handle /edits* { + reverse_proxy localhost:8000 + } + + handle /patches* { + reverse_proxy localhost:8000 + } + + handle /generate* { + reverse_proxy localhost:8000 + } + + handle /health { + reverse_proxy localhost:8000 + } + + handle /docs { + reverse_proxy localhost:8000 + } + + handle /openapi.json { + reverse_proxy localhost:8000 + } +} + +# Alternative: Use IP:Port format (no domain) +# :8080 { +# reverse_proxy localhost:3080 +# +# handle /projects* { +# reverse_proxy localhost:8000 +# } +# handle /edits* { +# reverse_proxy localhost:8000 +# } +# handle /patches* { +# reverse_proxy localhost:8000 +# } +# handle /generate* { +# reverse_proxy localhost:8000 +# } +# } diff --git a/docker-compose.yml b/docker-compose.yml index 803fc1a..6420882 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,7 +28,7 @@ services: dockerfile: Dockerfile container_name: ai-photo-edit-frontend ports: - - "80:80" + - "3080:80" # Frontend on port 3080 depends_on: - backend restart: unless-stopped diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 9196674..4f650ef 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -16,7 +16,7 @@ server { try_files $uri $uri/ /index.html; } - # API proxy + # API proxy - proxy all API routes to backend location /projects { proxy_pass http://backend:8000; proxy_http_version 1.1; @@ -35,6 +35,36 @@ server { proxy_cache_bypass $http_upgrade; } + location /patches { + 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_cache_bypass $http_upgrade; + } + + location /generate { + 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_cache_bypass $http_upgrade; + } + + location /health { + proxy_pass http://backend:8000; + } + + location /docs { + proxy_pass http://backend:8000; + } + + location /openapi.json { + proxy_pass http://backend:8000; + } + # Cache static assets location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y;