126 lines
3.4 KiB
Nginx Configuration File
126 lines
3.4 KiB
Nginx Configuration File
user nginx;
|
|
worker_processes auto;
|
|
error_log /var/log/nginx/error.log warn;
|
|
pid /var/run/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
use epoll;
|
|
multi_accept on;
|
|
}
|
|
|
|
http {
|
|
include mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
keepalive_timeout 65;
|
|
keepalive_requests 100000;
|
|
|
|
variables_hash_max_size 2048;
|
|
server_names_hash_bucket_size 128;
|
|
server_tokens off;
|
|
|
|
resolver 8.8.8.8 valid=30s ipv6=off;
|
|
resolver_timeout 11s;
|
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
# JSON format — preferred for log aggregators (ELK, Loki, Datadog, etc.)
|
|
log_format json_log escape=json
|
|
'{'
|
|
'"time":"$time_iso8601",'
|
|
'"remote_addr":"$remote_addr",'
|
|
'"method":"$request_method",'
|
|
'"uri":"$request_uri",'
|
|
'"status":$status,'
|
|
'"bytes_sent":$body_bytes_sent,'
|
|
'"request_time":$request_time,'
|
|
'"upstream_response_time":"$upstream_response_time",'
|
|
'"referer":"$http_referer",'
|
|
'"user_agent":"$http_user_agent",'
|
|
'"x_forwarded_for":"$http_x_forwarded_for",'
|
|
'"host":"$host"'
|
|
'}';
|
|
|
|
|
|
access_log /var/log/nginx/access.log json_log;
|
|
error_log /var/log/nginx/error.log;
|
|
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
types_hash_max_size 2048;
|
|
|
|
# Important for MinIO
|
|
client_max_body_size 0;
|
|
proxy_buffering off;
|
|
proxy_request_buffering off;
|
|
|
|
# Increase the buffer for the request line and headers
|
|
client_header_buffer_size 16k;
|
|
large_client_header_buffers 4 32k;
|
|
|
|
# If using Nginx as a proxy to the Harbor core/registry
|
|
proxy_buffer_size 16k;
|
|
proxy_buffers 4 32k;
|
|
proxy_busy_buffers_size 64k;
|
|
|
|
proxy_connect_timeout 300;
|
|
proxy_send_timeout 300;
|
|
proxy_read_timeout 300;
|
|
|
|
# Add extra headers
|
|
add_header X-Frame-Options DENY;
|
|
add_header Content-Security-Policy "frame-ancestors 'none'";
|
|
|
|
# SSL Settings
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_timeout 10m;
|
|
|
|
|
|
# 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/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
|
|
|
|
|
|
# Include all server configurations
|
|
include /etc/nginx/conf.d/*.conf;
|
|
}
|
|
|
|
# Existing http {} block stays as-is...
|
|
|
|
# TCP stream proxy for SMTP ports
|
|
# stream {
|
|
|
|
# upstream mailserver_smtp {
|
|
# server mailserver:25; # docker-mailserver container name
|
|
# }
|
|
|
|
# upstream mailserver_submission {
|
|
# server mailserver:587;
|
|
# }
|
|
|
|
# # Port 25 — inbound MTA-to-MTA (if you ever receive external mail)
|
|
# server {
|
|
# listen 25;
|
|
# proxy_pass mailserver_smtp;
|
|
# proxy_timeout 1m;
|
|
# proxy_connect_timeout 10s;
|
|
# }
|
|
|
|
# # Port 587 — STARTTLS submission (for mail clients or apps)
|
|
# server {
|
|
# listen 587;
|
|
# proxy_pass mailserver_submission;
|
|
# proxy_timeout 1m;
|
|
# proxy_connect_timeout 10s;
|
|
# }
|
|
# } |