Skip to content

Instantly share code, notes, and snippets.

@JcBanks
Created August 26, 2014 13:56
Show Gist options
  • Save JcBanks/7748ca3bc912650efdb9 to your computer and use it in GitHub Desktop.
Save JcBanks/7748ca3bc912650efdb9 to your computer and use it in GitHub Desktop.
nginx.conf - lost request research
worker_processes 6;
worker_rlimit_nofile 10240;
timer_resolution 500ms;
pid /var/run/nginx.pid;
events {
worker_connections 10240;
# Accept as many connections as possible, after nginx gets notification about a new connection.
# May flood worker_connections, if that option is set too low.
multi_accept on;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
keepalive_requests 2000;
reset_timedout_connection on;
client_body_timeout 10;
client_header_timeout 10;
client_header_buffer_size 128;
send_timeout 2;
# Use Host header instead of server_name for redirects:
server_name_in_redirect off;
#Don’t tell the world the intimate details of our nginx installation
server_tokens off;
# Caches information about open FDs, freqently accessed files.
# http://dak1n1.com/blog/12-nginx-performance-tuning
# Changing this setting, in my environment, brought performance up from 560k req/sec, to 904k req/sec.
# I recommend using some varient of these options, though not the specific values listed below.
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
gzip on;
gzip_http_version 1.0;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_comp_level 2;
gzip_min_length 0;
gzip_proxied expired no-cache no-store private auth;
gzip_buffers 4 16k;
gzip_types application/json text/plain text/css application/x-javascript text/xml application/xml application/rss+xml text/javascript;
upstream app {
# Path to Unicorn SOCK file, as defined previously
server unix:/var/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 443 ssl;
server_name _;
ssl on;
ssl_certificate /usr/local/nginx/ssl/webapp.crt;
ssl_certificate_key /usr/local/nginx/ssl/webapp.key;
# SSL Settings
# http://nginx.org/en/docs/http/configuring_https_servers.html
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM;
access_log logs/webapp.access.ssl.log main;
error_log logs/webapp.error.ssl.log notice;
# Application root, as defined previously
root /var/www/webapp/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-FORWARDED-PROTO https;
proxy_redirect off;
proxy_pass http://app;
}
location = /favicon.ico {
alias /var/www/webapp/public/assets/scc_favicon.ico;
}
location = /assets/favicon.ico {
alias /var/www/webapp/public/assets/scc_favicon.ico;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20m;
keepalive_timeout 10;
# Headersmore Nginx Fingerprinting header removal
#********************************************************************
#
# Clear Server Header
more_clear_headers 'Server';
# Clear X-Powered-By header
more_clear_headers 'X-Powered-By';
}
server {
listen 80;
server_name _;
access_log logs/webapp.access.log main;
error_log logs/webapp.error.log notice;
# Application root, as defined previously
root /var/www/webapp/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app;
}
location = /favicon.ico {
alias /var/www/webapp/public/assets/scc_favicon.ico;
}
location = /assets/favicon.ico {
alias /var/www/webapp/public/assets/scc_favicon.ico;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20m;
keepalive_timeout 10;
# Headersmore Nginx Fingerprinting header removal
#********************************************************************
#
# Clear Server Header
more_clear_headers 'Server';
# Clear X-Powered-By header
more_clear_headers 'X-Powered-By';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment