# /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
worker_cpu_affinity auto;
error_log stderr warn;
pcre_jit on;
error_log /var/log/nginx/error.log warn;
include /etc/nginx/modules/*.conf;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_tokens off;
client_max_body_size 10m;
sendfile on;
tcp_nopush on;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:2m;
ssl_session_timeout 1h;
ssl_session_tickets off;
# Enable high-level gzip compression.
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_proxied any;
# Helper variable for proxying websockets.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Specifies the main log format.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$request_time $upstream_response_time $pipe $upstream_cache_status';
log_format cloudwatch '{'
'"time":"$time_local",'
'"response-bytes": "$body_bytes_sent",'
'"bytes_sent": "$bytes_sent",'
'"time-taken-request-microseconds": "$request_time",'
'"remoteIP": "$http_x_forwarded_for",'
'"host": "$http_host",'
'"request": "$request",'
'"request_length":"$request_length",'
'"query": "$uri",'
'"method": "$request_method",'
'"status": "$status",'
'"userAgent":"$http_user_agent",'
'"referer": "$http_referer"'
'}';
access_log /var/log/nginx/access.log cloudwatch;
error_log /var/log/nginx/error.log warn;
# Includes virtual hosts configs.
include /etc/nginx/conf.d/*.conf;
}
# TIP: Uncomment if you use stream module.
#include /etc/nginx/stream.conf;