Skip to content

Instantly share code, notes, and snippets.

@tlesh989
Last active March 2, 2022 14:25
Show Gist options
  • Save tlesh989/56293a4d9151551e0fdd4f8fd637f4cb to your computer and use it in GitHub Desktop.
Save tlesh989/56293a4d9151551e0fdd4f8fd637f4cb to your computer and use it in GitHub Desktop.
basic nginx config with clean logging
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
map $http_user_agent $ignore_status_checks {
default 0;
"~Pingdom.*" 1;
"~*\(health\)" 1;
"~*Monit" 1;
}
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;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 8000;
location / {
if ($ignore_status_checks) {
access_log off;
}
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_pass http://app:3000;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
proxy_connect_timeout 60s;
proxy_http_version 1.1;
proxy_request_buffering off;
}
location /health {
access_log off;
error_log /dev/stderr error;
proxy_pass http://app:3000;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment