Nginx配置指南
对Nginx的学习并不多,但使用起来特别顺手且心中莫名放心,本文分享一份自己的nginx配置,并选择其中的一些配置项做些说明。
配置文件
nginx配置文件默认存放在/etc/nginx/nginx.conf,里面主要是http上下文的配置内容,而server等内容常被拆分成子文件通过include引入,以下是自己的nginx配置内容:
user root;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 512;
use epoll;
accept_mutex on;
}
http {
include /etc/nginx/mime.types; # mime type表
default_type text/plain; # response默认content-type
charset utf8; # 字符编码
server_tokens off;
access_log /var/log/nginx/access.log main;
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$host"';
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_requests 1000000;
keepalive_timeout