WeightTracker/nginx.conf

46 lines
1.5 KiB
Nginx Configuration File

server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Enable gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Main application location
# API proxy: All requests to /app-data/* will be forwarded to the Node.js API
location /app-data/ {
include /etc/nginx/nginx-auth.conf; # Apply Basic Auth to API
proxy_pass http://localhost:3000/; # Assuming Node API runs on port 3000
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
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;
}
location / {
include /etc/nginx/nginx-auth.conf; # Apply Basic Auth to the whole site
try_files $uri $uri/ /index.html;
}
# Enable browser caching for static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
include /etc/nginx/nginx-auth.conf; # Apply Basic Auth to static assets too
expires 30d;
add_header Cache-Control "public, no-transform";
}
# Error pages
error_page 404 /index.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}