- Add GetMetrics method to MetricsClient interface and implement cluster metrics API - Add QuotaPrecheck service for validating resource quotas before deployment - Add auth DTO with role/permission models and auth handler tests - Add instance diagnostics: mounted NFS volumes, labels, annotations in pod diagnostics - Update workspace handler with GetWorkspace endpoint and shared-user list - Fix monitoring handler to use correct service method name - Add tail_lines fallback in instance handler for snake_case query params - Update nginx config for SSE log streaming support (no buffering) - Add comprehensive test coverage: auth_service_test, auth_handler_test, auth_dto_test, metrics_client_test, quota_precheck_test - Update error messages for quota validation and instance operations - ModifyModal: fix YAML lineWidth:0, modified keys summary, delta-only submit - InstanceCard: correctly disable scale-minus when replicas <= 0 - SidebarLayout: add hover transition for sidebar items - Update todo.md and lessons.md with latest fixes
77 lines
3.4 KiB
Plaintext
77 lines
3.4 KiB
Plaintext
# default.conf - OCDP production gateway
|
||
# - 对外监听 80/443(Docker 默认映射宿主 80/443)
|
||
# - 路由策略: /api/* → backend 服务,其余路径 → SPA 静态资源
|
||
# - TLS 证书通过 /etc/nginx/certs/tls.(crt|key) 挂载,可替换为正式证书
|
||
|
||
server {
|
||
listen 80 default_server;
|
||
listen 443 ssl http2 default_server;
|
||
server_name _;
|
||
server_tokens off;
|
||
|
||
ssl_certificate /etc/nginx/certs/tls.crt;
|
||
ssl_certificate_key /etc/nginx/certs/tls.key;
|
||
ssl_session_cache shared:SSL:10m;
|
||
ssl_session_timeout 10m;
|
||
ssl_protocols TLSv1.2 TLSv1.3;
|
||
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256';
|
||
ssl_prefer_server_ciphers on;
|
||
|
||
root /usr/share/nginx/html;
|
||
index index.html;
|
||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||
|
||
add_header X-Frame-Options "DENY" always;
|
||
add_header X-Content-Type-Options "nosniff" always;
|
||
add_header Referrer-Policy "no-referrer" always;
|
||
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' http: https: ws: wss:; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always;
|
||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||
|
||
# 前端 SPA 路由 fallback
|
||
location / {
|
||
try_files $uri /index.html;
|
||
}
|
||
|
||
# API 请求代理到 backend 服务
|
||
location /api/ {
|
||
set $backend_upstream http://backend:8080;
|
||
proxy_pass $backend_upstream;
|
||
proxy_http_version 1.1;
|
||
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;
|
||
}
|
||
|
||
# 外部健康检查,避免 /health 落到 SPA
|
||
location = /health {
|
||
access_log off;
|
||
default_type application/json;
|
||
return 200 '{"status":"ok"}';
|
||
}
|
||
|
||
# Nginx 健康检查
|
||
location = /healthz {
|
||
access_log off;
|
||
add_header Content-Type text/plain;
|
||
add_header X-Frame-Options "DENY" always;
|
||
add_header X-Content-Type-Options "nosniff" always;
|
||
add_header Referrer-Policy "no-referrer" always;
|
||
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' http: https: ws: wss:; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always;
|
||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||
return 200 'ok';
|
||
}
|
||
|
||
# 提供静态资源 (cache control)
|
||
location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico)$ {
|
||
expires 7d;
|
||
add_header Cache-Control "public, max-age=604800, immutable";
|
||
add_header X-Frame-Options "DENY" always;
|
||
add_header X-Content-Type-Options "nosniff" always;
|
||
add_header Referrer-Policy "no-referrer" always;
|
||
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' http: https: ws: wss:; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always;
|
||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||
try_files $uri /index.html;
|
||
}
|
||
}
|