nginx 是一个高性能的http和反向代理 服务器,也是一个imap/pop3/smtp代理服务器
user ben woyoudever; #工作进程使用的用户和组
worker_processes 10; #打开的工作进程数,应该是cpu的个数
worker_rlimit_nofile 10240; #指定一个进程最多打开的文件数 最好与ulimit -n 保持一致
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #错误日志以及错误等级 [debug|info|notice|warn|error|crit]
pid logs/nginx.pid; #nginx主进程的pid数
events {
#use [kqueue|rtsig|epoll|poll|select]
use epoll; #使用epoll网络 I/O模型
worker_connections 65535; #单个进程的最大连接数
}
http {
include mime.types; #文件扩展名和文件类型映射表
default_type application/octet-stream; #默认文件格式
charset gb2312,utf-8; #默认编码
server_names_hash_bucket_size 128; #服务器名称的hash表大小
#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 logs/access.log main;
client_header_buffer_size 4K; #客户端头的缓冲区大小
open_file_cache max=10240 inactive=20s; #打开文件的缓冲
open_file_cache_valid 30s; #多久时间检查一下缓存的有效信息
open_file_cache_min_uses 1; #最少使用次数
sendfile on; #开启高效网络传输
tcp_nopush on; #防止网络阻塞
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 65; #keepalive超时时间
gzip on; #是否开启压缩模块,要用到cpu
zip_min_length 1k; #最小压缩文件大小
gzip_buffers 4 16k; #压缩缓冲区
gzip_http_version 1.0; #压缩版本
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml; #压缩的类型
gzip_vary on;
client_max_body_size 8m; #上传文件大小限制
fastcgi_connect_timeout 300; #fastcgi连接超时时间
fastcgi_send_timeout 300; #发送超时时间
fastcgi_read_timeout 300; #读取超时时间
fastcgi_buffer_size 64k; #缓冲区大小
fastcgi_buffers 4 64k; #设置多大的缓冲区缓冲
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_cache TEST; #开启fastcgi缓存
fastcgi_cache_valid 200 302 1h; #200 302应答一个小是
fastcgi_cache_valid 301 1d;
fastcgi_cache_valid any 1m;
fastcgi_cache_min_uses 1;
upstream backend_server { #后端负载
#server 192.168.10.22:80 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.10.27:80 weight=1 max_fails=2 fail_timeout=30s;
#server 192.168.10.20:80 weight=1 max_fails=2 fail_timeout=30s;
}
server {
listen 808;
server_name localhost; #绑定的域名
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
#查看nginx状态 要添加 --with-http_stub_status_module模块
location /nginxstatus{
sub_status on;
access_log on;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}