92 lines
2.5 KiB
Nginx Configuration File
92 lines
2.5 KiB
Nginx Configuration File
|
|
user www-data;
|
||
|
|
worker_processes auto;
|
||
|
|
pid /run/nginx.pid;
|
||
|
|
include /etc/nginx/modules-enabled/*.conf;
|
||
|
|
|
||
|
|
events {
|
||
|
|
worker_connections 768;
|
||
|
|
multi_accept on;
|
||
|
|
use epoll;
|
||
|
|
}
|
||
|
|
|
||
|
|
http {
|
||
|
|
# Basic Settings
|
||
|
|
sendfile on;
|
||
|
|
tcp_nopush on;
|
||
|
|
tcp_nodelay on;
|
||
|
|
keepalive_timeout 65;
|
||
|
|
types_hash_max_size 2048;
|
||
|
|
client_max_body_size 100m;
|
||
|
|
|
||
|
|
include /etc/nginx/mime.types;
|
||
|
|
default_type application/octet-stream;
|
||
|
|
|
||
|
|
# SSL Settings
|
||
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||
|
|
ssl_prefer_server_ciphers on;
|
||
|
|
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384;
|
||
|
|
|
||
|
|
# Logging Settings
|
||
|
|
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;
|
||
|
|
|
||
|
|
# Gzip Settings
|
||
|
|
gzip on;
|
||
|
|
gzip_vary on;
|
||
|
|
gzip_proxied any;
|
||
|
|
gzip_comp_level 6;
|
||
|
|
gzip_types
|
||
|
|
text/plain
|
||
|
|
text/css
|
||
|
|
text/xml
|
||
|
|
text/javascript
|
||
|
|
application/json
|
||
|
|
application/javascript
|
||
|
|
application/xml+rss
|
||
|
|
application/atom+xml
|
||
|
|
image/svg+xml;
|
||
|
|
|
||
|
|
# Rate limiting
|
||
|
|
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
|
||
|
|
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
|
||
|
|
|
||
|
|
# Default server block (catchall)
|
||
|
|
server {
|
||
|
|
listen 80 default_server;
|
||
|
|
listen [::]:80 default_server;
|
||
|
|
server_name _;
|
||
|
|
|
||
|
|
# API proxy for management interface
|
||
|
|
location /api/ {
|
||
|
|
limit_req zone=api burst=20 nodelay;
|
||
|
|
proxy_pass http://127.0.0.1:3000;
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
|
||
|
|
# Login rate limiting
|
||
|
|
location /api/auth/login {
|
||
|
|
limit_req zone=login burst=5 nodelay;
|
||
|
|
proxy_pass http://127.0.0.1:3000;
|
||
|
|
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 response for unconfigured domains
|
||
|
|
location / {
|
||
|
|
return 404 "Domain not configured";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Include proxy configurations
|
||
|
|
include /etc/nginx/conf.d/*.conf;
|
||
|
|
}
|