• nginx配置文件详解


    #user  nobody;
    #
    #开启的worker数量,这里保存和cpu数量一致
    worker_processes  6;
    worker_cpu_affinity 000001 000010 000100 001000 010000 100000;
    
    #制定error日志的格式为crit(error日志有六种格式:debug | info | notice | warn | error | crit;其中debug格式记录的错误信息最详细,crit记录的最少)
    error_log  /usr/local/nginx/logs/nginx_error.log crit;
    #指定nginx启动时的pid文件的路径
    pid        /usr/local/nginx/logs/nginx.pid;
    #指定nginx进程最多能够打开多少个文件描述符,通常与系统中的ulimit -n 的执行结果保持一致,ulimit -n执行的结果为系统一个进程最多能打开的文件数量
    worker_rlimit_nofile 204800;
    
    #事件区域配置
    events {
        #指定处理模型为epoll
        use epoll;
        #每个进程最多能处理的连接数
        worker_connections  204800;
    }
    
    
    #http服务配置区域
    http {
    	#指定文件扩展名和文件类型映射表
    	include       mime.types;
    	#指定文件类型
    	default_type  application/octet-stream;
    	
    	#指定字符集
    	charset utf-8;
    	
    	#服务器名字的hash表大小
    	server_names_hash_bucket_size 128;
    	
    	#指定客户端请求头部的缓存大小
    	client_header_buffer_size 2k;
    	#指定客户端请求中较大的消息头的缓存数量和大小
    	large_client_header_buffers 4 4k;
    	#指定客户端请求的单个文件的最大字节数
    	
    	client_max_body_size 8m;
    	#开启高效传输模式
    	sendfile        on;
    	#防止网络阻塞
    	tcp_nopush on;
       
    	#客户端连接超时时间 
    	keepalive_timeout 60;
    	
    	#FastCGI相关参数是为了改善网站的性能,减少资源占用,提高访问速度
    	#配置fastcgi缓存路径个目录结构等级
    	fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2
    	#关键字区域存储时间共和非活动连接删除时间
    	keys_zone=TEST:10m  inactive=5m;
    	#连接到后端fastcgi的超时时间
    	fastcgi_connect_timeout 300;
    	#向FastCGI传送请求的超时时间
    	fastcgi_send_timeout 300;
    	#接收FastCGI应答的超时时间
    	fastcgi_read_timeout 300;
    	#指定读取FastCGI应答第一部分需要多大的缓冲区
    	fastcgi_buffer_size 4k;
    	#指定本地需要用多少和多大的缓冲区来缓冲FastCGI的应答请求
    	fastcgi_buffers 8 4k;
    	#通常为fastcgi_buffer_size大小的两倍
    	fastcgi_busy_buffers_size 8k;
    	#写入缓存文件时使用多大的数据块,大小同上
    	fastcgi_temp_file_write_size 8k;
    	#开启Fastcgi的缓存并且为其指定一个名称
    	fastcgi_cache TEST;
    	#指定不同的状态码,其缓存的时间
    	fastcgi_cache_valid 200 302 1h;
    	#URL经过被访问多少次将被缓存
    	fastcgi_cache_valid 301 1d;
    	fastcgi_cache_valid any 1m;
    	fastcgi_cache_min_uses 1;
    	#指定什么情况下不进行缓存
    	fastcgi_cache_use_stale error timeout invalid_header http_500;
    	#指定缓存文件最大数量,经过多长时间文件没有被请求后则删除缓存
    	open_file_cache max=204800  inactive=20s;
    	#指令中的inactive参数时间内文件的最少使用次数,如果超过这个数字,文件更改信息一直是在缓存中打开的;
    	open_file_cache_min_uses 1;
    	#指定多长时间检查一次缓存的有效信息,检查该缓存的源文件是否发生变化修改等
    	open_file_cache_valid 30s;
    	# nagle算法,有需要发送的就立即发送,连接转换为长连接时使用;
    	tcp_nodelay on;
    
    	#开启gzip压缩
    	gzip on;
    	#指定最小压缩文件的大小
    	gzip_min_length 1k;
    	#指定压缩缓冲区的个数和格式
    	gzip_buffers 4 16k;
    	#指定压缩版本
    	gzip_http_version 1.0;
    	#指定压缩等级,1-9级,9的压缩级别最高
    	gzip_comp_level 2;
    	#指定压缩文件类型
    	gzip_types  text/plain application/x-javascript text/css application/xml;
    	#前端缓存服务器缓存经过压缩的页面
    	gzip_vary on;
    	
    	#配置日志格式,日志格式为access
    	log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
                                      '$status $body_bytes_sent "$http_referer" '
                                      '"$http_user_agent" $http_x_forwarded_for';

      

    server	{
    		listen 80;
    		server_name www.linuxfan.cn;
    		
    		location / {
    			root /usr/local/nginx/html/;
    			proxy_pass http://*.*.*.*:8080;#开启nginx代理到指定地址
    			index index.html index.html;
    		}
    		
    
    
          #nginx状态页面 
    		location /status {
    
    			stub_status on;
    			access_log off;
    		}
    	
    		location ~ .*.(gif|jgp|jpeg|png|bmp|swf|js|css)$ {
    			expires 30d;		#指定以上格式的文件将进行缓存
    		}
    	
    		access_log /usr/local/nginx/access.log access;
    		
    		}
    
    }
    

      

  • 相关阅读:
    ADERA3 省选模拟赛 SPOJ LMCONST
    TYVJ 1730 二逼平衡树 线段树套平衡树
    BZOJ 1059 [ZJOI2007]矩阵游戏 二分图匹配
    BZOJ 1056 [HAOI2008]排名系统 Splay+Hash
    OI教会我的
    BZOJ 1055 [HAOI2008]玩具取名 DP
    BZOJ 1058 [ZJOI2007]报表统计 Splay
    为自己而奋斗
    [总结]高斯消元&XOR方程
    我 的 2013
  • 原文地址:https://www.cnblogs.com/kjjmj/p/11108178.html
Copyright © 2020-2023  润新知