2026-03-06 20:14:50 +07:00
|
|
|
server {
|
fix(install): unblock self-hosting + drop forced wokwi clones
Resolves several install pain points reported by users (#108, #120) and
removes the obligatory upstream-clone step that confused contributors and
slowed down every Docker build.
Install fixes:
- nginx: server_name → catch-all default_server, drop Debian's stock site
so reverse-proxied users no longer get the "Welcome to nginx" page.
- entrypoint: auto-generate SECRET_KEY at first boot, persisted under
data/.secret_key. backend/.env is now optional in docker-compose.yml.
- backend: add greenlet>=3.0.0 (SQLAlchemy async dep that was missing on
some Python builds — caused uvicorn startup failures on WSL).
Wokwi libs come from npm:
- @wokwi/elements 1.9.2, avr8js 0.21.0, rp2040js 1.3.2 are pinned in
frontend/package.json. Vite aliases removed.
- Dockerfile.standalone no longer clones avr8js / rp2040js / wokwi-elements
/ wokwi-boards. Frontend stage is just COPY + npm install + build:docker.
- Board SVGs vendored under frontend/public/boards/ (10 deduped against
existing files, 2 truly new). third-party/wokwi-* clones become reference-
only credits — generate-component-metadata.ts skips gracefully when absent.
Production config split out:
- docker-compose.prod.yml, deploy/nginx.prod.conf, nginx-host-velxio*.conf,
update-third-party.bat removed. Production deployment lives in its own
repo: https://github.com/velxio/velxio-prod (host nginx + HTTPS + backups
+ pinned upstream commit).
Verified locally: 1161 frontend tests pass, build:docker completes clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 10:04:11 +07:00
|
|
|
listen 80 default_server;
|
|
|
|
|
listen [::]:80 default_server;
|
|
|
|
|
server_name _;
|
2026-03-06 20:14:50 +07:00
|
|
|
root /usr/share/nginx/html;
|
|
|
|
|
index index.html;
|
|
|
|
|
|
2026-03-07 03:20:44 +07:00
|
|
|
# Security headers
|
|
|
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
|
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
|
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
|
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
|
|
|
|
2026-03-12 01:55:18 +07:00
|
|
|
# SEO crawler files — never cache so Googlebot always gets the latest version
|
|
|
|
|
location = /sitemap.xml {
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
add_header Cache-Control "no-cache, must-revalidate";
|
|
|
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location = /robots.txt {
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
add_header Cache-Control "no-cache, must-revalidate";
|
2026-03-06 20:14:50 +07:00
|
|
|
}
|
|
|
|
|
|
2026-03-07 03:20:44 +07:00
|
|
|
# Health check endpoint
|
2026-03-12 01:55:18 +07:00
|
|
|
location = /health {
|
2026-03-07 03:20:44 +07:00
|
|
|
proxy_pass http://127.0.0.1:8001/health;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 03:02:23 +07:00
|
|
|
# WebSocket endpoints (ESP32 simulation, etc.)
|
|
|
|
|
# Must come BEFORE the generic /api/ block so nginx matches it first.
|
|
|
|
|
location /api/simulation/ws/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:8001/api/simulation/ws/;
|
|
|
|
|
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_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
proxy_read_timeout 86400s;
|
|
|
|
|
proxy_send_timeout 86400s;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-12 01:55:18 +07:00
|
|
|
# Proxy /api/* requests to the FastAPI backend.
|
|
|
|
|
# FastAPI Swagger UI is at /api/docs (moved from /docs to avoid
|
|
|
|
|
# conflicting with the frontend /docs/* documentation routes).
|
2026-03-06 20:14:50 +07:00
|
|
|
location /api/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:8001/api/;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
2026-03-07 03:20:44 +07:00
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2026-03-06 20:14:50 +07:00
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
2026-05-04 20:15:11 +07:00
|
|
|
proxy_read_timeout 600s;
|
2026-03-07 03:20:44 +07:00
|
|
|
proxy_connect_timeout 75s;
|
2026-03-06 20:14:50 +07:00
|
|
|
}
|
|
|
|
|
|
2026-03-12 01:55:18 +07:00
|
|
|
# Cache static assets with content-hash filenames (js/css/fonts/images)
|
|
|
|
|
location ~* \.(js|css|woff|woff2|ttf|eot)$ {
|
2026-03-06 20:14:50 +07:00
|
|
|
expires 1y;
|
|
|
|
|
add_header Cache-Control "public, immutable";
|
|
|
|
|
}
|
2026-03-07 03:20:44 +07:00
|
|
|
|
2026-03-12 01:55:18 +07:00
|
|
|
location ~* \.(png|jpg|jpeg|gif|ico|svg|webp)$ {
|
|
|
|
|
expires 30d;
|
|
|
|
|
add_header Cache-Control "public";
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-07 03:20:44 +07:00
|
|
|
# Gzip compression
|
|
|
|
|
gzip on;
|
|
|
|
|
gzip_vary on;
|
|
|
|
|
gzip_min_length 1024;
|
|
|
|
|
gzip_proxied any;
|
2026-03-12 01:55:18 +07:00
|
|
|
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml application/rss+xml;
|
|
|
|
|
|
|
|
|
|
# Frontend SPA routing — must be last so specific locations above take precedence
|
|
|
|
|
location / {
|
|
|
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
|
}
|
2026-03-06 20:14:50 +07:00
|
|
|
}
|