Files

88 lines
2.5 KiB
Nginx Configuration File

server {
listen 80;
server_name localhost;
client_max_body_size 100M;
root /usr/share/nginx/html;
index index.html;
include /etc/nginx/mime.types;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Favicon handling
location = /favicon.ico {
try_files $uri /favicon.svg =200;
access_log off;
log_not_found off;
}
# Priority prefix location for uploads - proxies to Express backend container
location ^~ /uploads/ {
proxy_pass http://backend:3005/uploads/;
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_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Priority prefix location for backend API
location ^~ /api/ {
proxy_pass http://backend:3005/api/;
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;
# Prevent 504 Gateway Timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Explicit handling for static JS, CSS, images, and fonts
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|map)$ {
try_files $uri /citpl_website$uri =404;
expires 30d;
add_header Cache-Control "public, no-transform";
}
# Handle React SPA routing for main site
location / {
try_files $uri $uri/ /index.html;
}
# Support /citpl_website/ prefix routing
location /citpl_website/ {
alias /usr/share/nginx/html/;
try_files $uri $uri/ /index.html;
}
# Handle Admin SPA routing
location /admin {
try_files $uri $uri/ /admin.html;
}
# Handle Preview SPA routing
location /preview {
try_files $uri $uri/ /preview.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}