ee509cd48b
Diplodoc CLI 4.60 bug: HTML refs hashed asset names (например `_bundle/app-34c68624e23be7ce.css`) но actual built _bundle/ contains unhashed files (`app.css`). Browser получает 404 на все css/js references → page broken. Workaround в nginx — strip hash через regex location: ^/docs/(_bundle|_assets)/(.+?)-<hex8+>(\.<ext>)$ → alias /usr/share/nginx/html/$1/$2$3 Также убран try_files который incorrectly matched $uri (URL path с hash) вместо aliased file path → false 404. Verified locally — 200 OK на: /docs/_bundle/app-34c68624e23be7ce.css /docs/_bundle/vendor-*.css /docs/_bundle/react-*.js /docs/integration/api/auth.html
55 lines
1.6 KiB
Nginx Configuration File
55 lines
1.6 KiB
Nginx Configuration File
# Ordinis Integrator Guide — nginx serving static HTML на /docs/.
|
|
# Diplodoc генерирует relative links — alias корректно работает без rewrite.
|
|
|
|
server {
|
|
listen 8080 default_server;
|
|
listen [::]:8080 default_server;
|
|
server_name _;
|
|
|
|
access_log /dev/stdout;
|
|
error_log /dev/stderr;
|
|
|
|
# K8s probe.
|
|
location = /healthz {
|
|
access_log off;
|
|
return 200 "ok\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
# Static assets (Diplodoc CLI 4.60 bug: HTML refs hashed names типа
|
|
# `_bundle/app-34c68624e23be7ce.css`, но actual файл — `app.css` (без
|
|
# hash). Strip hash в nginx через rewrite: `name-<hash>.ext` → `name.ext`.
|
|
location ~* "^/docs/(_bundle|_assets)/(.+?)-[a-f0-9]{8,}(\.[a-z0-9]+)$" {
|
|
alias /usr/share/nginx/html/$1/$2$3;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
# Non-hashed assets (fallback).
|
|
location ~* ^/docs/((_bundle|_assets)/.*\.(css|js|woff2?|ttf|eot|svg|png|jpg|jpeg|ico|map|json))$ {
|
|
alias /usr/share/nginx/html/$1;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# Documentation pages (HTML).
|
|
location /docs/ {
|
|
alias /usr/share/nginx/html/;
|
|
index index.html;
|
|
try_files $uri $uri/ $uri.html =404;
|
|
|
|
expires 5m;
|
|
add_header Cache-Control "public, must-revalidate";
|
|
}
|
|
|
|
# Redirect /docs (без trailing slash) → /docs/.
|
|
location = /docs {
|
|
return 301 /docs/;
|
|
}
|
|
|
|
# Security headers.
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
}
|