Files
oicd/nginx/nginx.conf
2025-11-30 00:07:24 +01:00

93 lines
2.6 KiB
Nginx Configuration File

events {
worker_connections 1024;
}
http {
# Basic settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
# SSL settings
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Rate limiting
limit_req_zone $binary_remote_addr zone=login_limit:10m rate=10r/m;
limit_req_zone $binary_remote_addr zone=general_limit:10m rate=100r/m;
# Upstream to OIDC server
upstream oidc_backend {
server oidc_server:5000;
}
# HTTP server - redirect to HTTPS
server {
listen 80;
server_name _;
# Allow Let's Encrypt ACME challenge
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
# Redirect all other traffic to HTTPS
location / {
return 301 https://$host$request_uri;
}
}
# HTTPS server
server {
listen 443 ssl http2;
server_name _; # Replace with your domain
# SSL certificates (use Let's Encrypt)
# Generate with: certbot certonly --webroot -w /var/www/certbot -d yourdomain.com
ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
# Security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Max upload size
client_max_body_size 10M;
# Proxy settings
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_redirect off;
# Health check endpoint (no rate limit)
location /health {
proxy_pass http://oidc_backend;
}
# Login endpoints with strict rate limiting
location ~ ^/(login|admin/login|authorize|token) {
limit_req zone=login_limit burst=5 nodelay;
proxy_pass http://oidc_backend;
}
# All other locations
location / {
limit_req zone=general_limit burst=20 nodelay;
proxy_pass http://oidc_backend;
}
}
}