Nginx基本配置文件详解与参数说明

#启动进程,通常设置成和cpu的数量相等
worker_processes 4;  
worker_cpu_affinity 0001 0010 0100 1000;
events {
    #单个后台worker process进程的最大并发链接数
    worker_connections  1024;
    multi_accept on;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    tcp_nopush     on;
    #连接超时时间
    keepalive_timeout  65;
    client_max_body_size 100m; 
    #设定请求缓冲
    client_header_buffer_size 10m;
    large_client_header_buffers 4 10m;
    gzip  on;
	
    #301重定向跳转
    server {
    	listen      80;
    	server_name    taobye.com;
    	return      301 https://www.taobye.com$request_uri;
    }
	
    #https部署方式
    server {
		listen 80;
		listen 443 ssl;
		ssl on;
		server_name www.taobye.com;
		ssl_certificate sslkey/www.taobye.com.cer;
		ssl_certificate_key sslkey/www.taobye.com.key;
		ssl_session_timeout 5m;
		ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
			ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
		location / {
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			root html;
			index index.jsp;
			proxy_pass http://127.0.0.1:8080; 
		}
    }
    
    #http部署方式
    server {
        listen 80;
        server_name ceshi.taobye.com;
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            index index.jsp;
            proxy_pass http://127.0.0.1:8081;    
        }
        error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

}
正在加载评论...