From 5ec264c8bc877c7139569e9e6a3f4cb32d6a5042 Mon Sep 17 00:00:00 2001 From: khondokartowsif171 Date: Sat, 5 Sep 2026 06:28:26 +0600 Subject: [PATCH] fix(coolify): add Traefik routing labels, coolify network, and zero-cache CDN headers --- docker-compose.yml | 25 +++++++++++++++++++++---- nginx.conf | 29 ++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7af69e1..93d10f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,27 @@ version: '3.8' services: opal-ios-studio: - build: . - restart: always + build: + context: . + dockerfile: Dockerfile container_name: opal-ios-studio - ports: - - "80" + restart: always environment: - NODE_ENV=production + - PORT=80 + networks: + - coolify + labels: + - "traefik.enable=true" + - "traefik.http.routers.opal-studio-http.entrypoints=http" + - "traefik.http.routers.opal-studio-http.rule=Host(`opal.auraajenticai.cloud`)" + - "traefik.http.routers.opal-studio-http.middlewares=redirect-to-https" + - "traefik.http.routers.opal-studio-https.entrypoints=https" + - "traefik.http.routers.opal-studio-https.rule=Host(`opal.auraajenticai.cloud`)" + - "traefik.http.routers.opal-studio-https.tls=true" + - "traefik.http.routers.opal-studio-https.tls.certresolver=letsencrypt" + - "traefik.http.services.opal-studio-svc.loadbalancer.server.port=80" + +networks: + coolify: + external: true diff --git a/nginx.conf b/nginx.conf index 346b4b0..8fa89cf 100644 --- a/nginx.conf +++ b/nginx.conf @@ -17,20 +17,31 @@ server { add_header X-Content-Type-Options "nosniff"; add_header Access-Control-Allow-Origin "*"; + # HTML pages must NEVER be cached by browser/CDN location / { try_files $uri $uri/ /index.html; - } - - # Cache Service Worker with no-cache so updates apply immediately - location = /sw.js { - add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; add_header Pragma "no-cache"; add_header Expires "0"; } - # Static assets cache - location ~* \.(css|js|json|svg|png|jpg|jpeg|ico)$ { - expires 7d; - add_header Cache-Control "public, max-age=604800, immutable"; + # Cache Service Worker with no-cache so updates apply immediately + location = /sw.js { + add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + + # Static assets with revalidation + location ~* \.(css|js|json)$ { + add_header Cache-Control "no-cache, must-revalidate, max-age=0"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + + # Images & icons + location ~* \.(svg|png|jpg|jpeg|ico|webp)$ { + expires 1d; + add_header Cache-Control "public, max-age=86400"; } }