NewsAtlas/nginx/nginx.conf

54 lines
1.3 KiB
Nginx Configuration File

worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
# Simple in-memory cache for upstream JSON responses so many globe
# clients don't hammer the backend/SQLite on every poll.
proxy_cache_path /tmp/newsatlas_cache levels=1:2 keys_zone=api_cache:10m max_size=100m inactive=5m;
upstream backend {
server backend:8000;
}
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://backend/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_cache api_cache;
proxy_cache_valid 200 30s;
proxy_cache_use_stale error timeout updating;
add_header X-Cache-Status $upstream_cache_status;
}
location /healthz {
access_log off;
return 200 "ok\n";
}
}
}