mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-12-03 05:08:56 +01:00
Preserve existing accounts, preferences and production data mounts. Serve compact catalog payloads and responsive WebP derivatives. Document measured improvements, remaining targets and rollback.
83 lines
3.5 KiB
Nginx Configuration File
83 lines
3.5 KiB
Nginx Configuration File
# Traefik terminates TLS; retain its public scheme through the internal hop.
|
|
map $http_x_forwarded_proto $public_scheme {
|
|
default $scheme;
|
|
https https;
|
|
}
|
|
# =========================================================================
|
|
# Frontend nginx: serves the SPA, proxies /api to the Rust backend
|
|
# (holy-rust:8001), and serves /media straight from the shared bind mount.
|
|
# The per-group /api locations are kept explicit (one proxy_pass each) for
|
|
# readability; all point at rust_backend. The catch-all /api/ covers anything
|
|
# not listed.
|
|
# =========================================================================
|
|
|
|
upstream rust_backend {
|
|
server holy-rust:8001;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 512;
|
|
gzip_types application/javascript application/json text/css image/svg+xml;
|
|
|
|
location /assets/ {
|
|
root /usr/share/nginx/html;
|
|
try_files $uri =404;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
location /media/_variants/ {
|
|
alias /usr/share/nginx/media/_variants/;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
|
|
# --- SPA -------------------------------------------------------------
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
index index.html index.htm;
|
|
try_files $uri $uri/ /index.html;
|
|
add_header Cache-Control "no-cache";
|
|
}
|
|
|
|
# --- API -> Rust backend ---------------------------------------------
|
|
# Longest-prefix match wins; these explicit groups and the catch-all
|
|
# /api/ all resolve to rust_backend.
|
|
location /api/categories/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
location /api/flavors/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
location /api/banners/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
|
|
location /api/auth/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
location = /api/token/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; } # legacy JWT alias
|
|
location /api/ratings/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
location /api/replies/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
location /api/users/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
location /api/notifications/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
location /api/tickets/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
|
|
location /api/admin-custom/ { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
|
|
# OpenAPI schema / Swagger UI:
|
|
location /api/schema { proxy_pass http://rust_backend; include /etc/nginx/proxy_params.conf; }
|
|
|
|
# Catch-all for any /api path not listed above.
|
|
location /api/ {
|
|
proxy_pass http://rust_backend;
|
|
include /etc/nginx/proxy_params.conf;
|
|
}
|
|
|
|
# --- Media -----------------------------------------------------------
|
|
# Served straight from the shared bind mount (read-only) so media does not
|
|
# depend on either backend being up — a prerequisite for retiring Django.
|
|
location /media/ {
|
|
alias /usr/share/nginx/media/;
|
|
access_log off;
|
|
expires 7d;
|
|
add_header Cache-Control "public";
|
|
try_files $uri =404;
|
|
}
|
|
}
|