nginx 高性能 配置 样例

user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
use epoll;
multi_accept off; #如果multi_accept被禁止了,nginx一个工作进程只能同时接受一个新的连接。否则,一个工作进程可以同时接受所有的新连接
reuse_port on;#SO_REUSEPORT支持多个进程或者线程绑定到同一端口,提高服务器程序的性能
worker_connections 1048576;
}
dso { # 动态加载功能模块 /usr/share/nginx/modules
load ngx_http_memcached_module.so;
load ngx_http_limit_conn_module.so;
load ngx_http_empty_gif_module.so;
load ngx_http_scgi_module.so;
load ngx_http_upstream_session_sticky_module.so;
load ngx_http_user_agent_module.so;
load ngx_http_referer_module.so;
load ngx_http_upstream_least_conn_module.so;
load ngx_http_uwsgi_module.so;
load ngx_http_reqstat_module.so;
load ngx_http_browser_module.so;
load ngx_http_limit_req_module.so;
load ngx_http_split_clients_module.so;
load ngx_http_upstream_ip_hash_module.so;
}
http {
include /etc/nginx/mime.types;
default_type text/plain;
access_log off;
sendfile on;
tcp_nopushon;
tcp_nodelayon;
server_tokens off;
keepalive_timeout 120;
server_names_hash_bucket_size 512;
server_name_in_redirect off;
fastcgi_connect_timeout 3s;
fastcgi_send_timeout 3s;
fastcgi_read_timeout 3s;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
variables_hash_max_size 1024;
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.28.0.0/16;
set_real_ip_from 192.168.0.0/16;
real_ip_header X-Forwarded-For;
gzip off;
gzip_disable “msie6”;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_vary on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server {
listen 80 backlog=65535;
charset utf-8;
location / { # 打印Tengine状态页
stub_status on; # 开启状态页,依赖 http_stub_status_module 模块
access_log off; #访问过程不记日志
}
location ~ ^(.*)/.(svn|git|hg|bzr|cvs)/ { # 屏蔽这些目录
deny all;
access_log off;
log_not_found off;
}
location ~ /. { # 屏蔽.开头的目录或文件,比如 .htaccess .bash_history
deny all;
access_log off;
log_not_found off;
}
location /do_not_delete.html {
access_log off;
empty_gif;
}
}
}

你可能感兴趣的:(nginx 高性能 配置 样例)