iloom/k8s/02-configmaps/frontend-nginx.yaml

67 lines
2.2 KiB
YAML
Raw Normal View History

apiVersion: v1
kind: ConfigMap
metadata:
name: iloom-frontend-nginx
namespace: iloom
data:
default.conf: |
server {
listen 3015;
server_name _;
root /usr/share/nginx/html;
index index.html;
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;
gzip_min_length 256;
location /api/ {
proxy_pass http://iloom-gateway:8080;
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;
client_max_body_size 10m;
}
location ^~ /uploads/ {
resolver 10.43.0.10 valid=30s;
set $minio_host "minio.iloom.svc.cluster.local";
rewrite ^/uploads/(.*)$ /iloom-uploads/$1 break;
proxy_pass http://$minio_host:9000;
proxy_set_header Host $minio_host:9000;
expires 7d;
add_header Cache-Control "public";
}
location /ws/ {
proxy_pass http://iloom-gateway:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 86400;
}
# SPA fallback — index.html must never be cached
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# Hashed static assets (e.g. main.decafe71.js) — safe to cache long-term
location ~* \.[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\.(js|css)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
# Other static assets (images, fonts) — moderate cache
location ~* \.(png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 7d;
add_header Cache-Control "public";
}
}