Skip to content

Instantly share code, notes, and snippets.

@awnion
Last active December 14, 2015 00:08
Show Gist options
  • Save awnion/4996212 to your computer and use it in GitHub Desktop.
Save awnion/4996212 to your computer and use it in GitHub Desktop.
My nginx.conf (base nginx config)
# Base nginx config
# See: http://habrahabr.ru/post/56497/ (russian)
user www-data;
worker_processes 2; # recommended equals to number of cores
pid /var/run/nginx.pid;
# Decrease calls of gettimeofday()
timer_resolution 100ms;
worker_priority -5; # from -20 to 20 (the lower the higher priority)
worker_rlimit_nofile 8192;
events {
worker_connections 8192; # increase if you have lots of clients
accept_mutex on; # recommended "off" if nginx worker_processes == 1
# multi_accept on;
use epoll; # enable for Linux 2.6+
# use kqueue; # enable for FreeBSD, OSX
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
tcp_nodelay off; # on may be better for some Comet/long-poll stuff
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
charset utf-8;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
# nginx will find this file in the config directory set at nginx build time
include /etc/nginx/mime.types;
# fallback in case we can't determine a type
default_type application/octet-stream;
##
# 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" $upstream_response_time';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
# we haven't checked to see if Rack::Deflate on the app server is
# faster or not than doing compression via nginx. It's easier
# to configure it all in one place here for static files and also
# to disable gzip for clients who don't get gzip/deflate right.
# There are other other gzip settings that may be needed used to deal with
# bad clients out there, see http://wiki.nginx.org/NginxHttpGzipModule
gzip on;
gzip_min_length 1400; #MTU
gzip_buffers 64 8k;
gzip_comp_level 3;
gzip_http_version 1.1;
gzip_proxied any;
# gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_disable "msie6";
gzip_types
text/plain
text/html
text/xml
text/css
text/comma-separated-values
text/javascript
application/json
application/x-javascript
application/atom+xml;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment