Files
jarvis-lan/nginx.conf
2025-12-28 23:45:20 +01:00

97 lines
3.0 KiB
Nginx Configuration File

server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Disable caching for all responses during debugging
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
# Favicon
location = /favicon.ico {
try_files /favicon.ico =204;
access_log off;
log_not_found off;
}
# Serve shared JS and CSS directories at root
location /js/ {
try_files $uri =404;
}
location /css/ {
try_files $uri =404;
}
# Custom 404 page
error_page 404 /404.html;
location = /404.html {
internal;
}
# Enable clean URLs without .html extension
location / {
# Try the exact URI, then with .html, then as directory with index.html, then 404
try_files $uri $uri.html $uri/ =404;
}
location = /index.html {
try_files /index.html =404;
}
# Proxy API requests to plato.lan (192.168.1.74)
location /api/plato/ {
proxy_pass http://192.168.1.74:8080/v1/;
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 API requests to stoic.lan (192.168.1.159)
location /api/stoic/ {
proxy_pass http://192.168.1.159:8081/v1/;
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 API requests to ollama (192.168.1.159:8081)
location /api/ollama/ {
proxy_pass http://192.168.1.159:8081/v1/;
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;
}
# Default /api/ points to plato for backwards compatibility
location /api/ {
proxy_pass http://192.168.1.74:8080/v1/;
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;
}
# Cache static assets with content hash - minimal caching
location ~* \.(js|css)$ {
expires 1s; # 1 second for rapid iteration
add_header Cache-Control "public, max-age=1, must-revalidate" always;
}
# Cache images and icons - short caching
location ~* \.(ico|png|svg|jpg|jpeg|gif|webp)$ {
expires 5s; # 5 seconds, adjust as needed
add_header Cache-Control "public, max-age=5, must-revalidate" always;
}
# Gzip compression for better performance
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
}