tinovisas/nginx/nginx.conf

92 lines
2.6 KiB
Nginx Configuration File

events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
upstream tinovisas_web {
server frontend:3000;
}
upstream tinovisas_api {
server backend:4000;
}
server {
listen 80;
server_name _;
client_max_body_size 50M;
# Health check
location /health {
access_log off;
proxy_pass http://tinovisas_api/health;
}
# Tinovisas API - preserve /api/ prefix
location /api/ {
proxy_pass http://tinovisas_api/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;
}
# Tinovisas static assets
location /_next/ {
proxy_pass http://tinovisas_web/_next/;
proxy_http_version 1.1;
proxy_cache_valid 200 1d;
add_header Cache-Control "public, immutable";
}
# Tinovisas screenshots
location /screenshots/ {
alias /app/screenshots/;
autoindex off;
expires 1d;
}
# Tinovisas uploads
location /uploads/ {
alias /app/uploads/;
expires 30d;
add_header Cache-Control "public, immutable";
}
# Tinovisas frontend - everything else
location / {
proxy_pass http://tinovisas_web;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}
}
}