Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_proxied any;
gzip_types
text/plain text/css text/javascript
application/javascript application/json image/svg+xml;
# API — proxy to local Go backend
location /api/ {
proxy_pass http://localhost:3000/api/;
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;
proxy_read_timeout 60s;
}
# Health check passthrough
location /health {
proxy_pass http://localhost:3000/health;
}
# W3C Change Password URL. Password managers (Safari Keychain, Chrome Password
# Checkup, 1Password) open this path to take a user straight to the change-password
# form. Exact-match so it wins over the SPA fallback, which would otherwise answer
# with index.html and leave React Router to bounce an unauthenticated visitor to
# /login. The dev/preview equivalent lives in web/vite.config.ts.
location = /.well-known/change-password {
# absolute_redirect off keeps the Location relative. With nginx's default (on) it
# would expand to an absolute URL built from $scheme — and this block listens on
# 80 behind a TLS terminator, so that scheme is http. A manager opening the https
# well-known URL would be bounced to cleartext and left to whatever the outer
# proxy does about it. Relative inherits the request's real scheme.
absolute_redirect off;
return 302 /settings/password;
}
# SPA fallback
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
}