strava-frontend/nginx.conf

62 lines
1.9 KiB
Nginx Configuration File

server {
listen 80;
server_name localhost;
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype;
# SSR routes (search bots + guests get real HTML)
location ~ ^/(explore|routes|sitemap\.xml|robots\.txt)$ {
proxy_pass http://127.0.0.1:3001;
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 Cookie $http_cookie;
}
# Public workout detail — SSR
location ~ ^/public/workouts/ {
proxy_pass http://127.0.0.1:3001;
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 Cookie $http_cookie;
}
# Landing page: SSR if no auth cookie, SPA if has token
location = / {
hascookie token .;
if ($cookie_token = "") {
proxy_pass http://127.0.0.1:3001;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
}
# If cookie present → fall through to static (SPA handles redirect)
root /usr/share/nginx/html;
try_files /index.html =404;
}
# Everything else → SPA
location / {
root /usr/share/nginx/html;
try_files $uri /index.html;
}
# Static assets
location /assets/ {
root /usr/share/nginx/html;
expires 30d;
add_header Cache-Control "public, immutable";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\. {
deny all;
}
}