Nginx生产环境调优

nginx443.conf

server{
#http2协议
		listen 443 ssl http2;
		server_name 10.10.101.1;
		
		#ssl on;
		ssl_certificate /etc/nginx/cert/server.crt;
		ssl_certificate_key /etc/nginx/cert/server.key;
		ssl_session_timeout 5m;
		ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
		ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
		ssl_prefer_server_ciphers on;
		proxy_buffering off;
#动静分离
		index st/index.html;
		root /opt/WEB_RELEASE/;
	
		location /demo/{
						#限流模块使用
						#	limit_req zone=one burst=200;
						#	limit_req zone=perserver burst=100;
						#	limit_req zone=one burst=200  nodelay;
						#	limit_req_status 599;
								
						#	limit_conn addr 1;
						#	limit_conn perserverconn 100;
						#	limit_conn_status 598;

#屏蔽方法
					    if ($request_method !~ ^(GET|HEAD|POST)$ ) {
								return 403;
						}
#防攻击
						add_header	Set-Cookie "HttpOnly";
						add_header	Set-Cookie "Secure";
						add_header	X-Frame-Options "SAMEORIGIN";
                        real_ip_header     X-Forwarded-For;
                        proxy_pass http://ups;
                        port_in_redirect off;
                }	
#白名单
		location /nginx_status {
						stub_status on;
						access_log off;
						allow 127.0.0.1;
						deny all;
		}
}

 

nginx.conf


user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {

use epoll;

worker_connections 65535;

multi_accept on;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
#版本号关闭
    server_tokens off;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
					  '$upstream_addr'
					  ' ups_resp_time:$upstream_response_time,request_time:$request_time';
    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    tcp_nopush     on;

	keepalive_timeout 60;
	tcp_nodelay on;
	client_header_buffer_size 4k;
	open_file_cache max=102400 inactive=20s;
	open_file_cache_valid 30s;
	open_file_cache_min_uses 1;
	client_header_timeout 15;
	client_body_timeout 15;
	reset_timedout_connection on;
	send_timeout 15;

    gzip  on;
	gzip_min_length 2k;
	gzip_buffers    4 32k;
	gzip_http_version 1.1;
	gzip_comp_level 6;
	gzip_types text/plain text/css text/javascriptapplication/json application/javascript application/x-javascriptapplication/xml;
	gzip_vary on;
	gzip_proxied any;
#请求大小限制
	client_max_body_size 500m;

    include /etc/nginx/conf.d/*.conf;
	
#负载均衡
	upstream ups {
		server 实际ip:8002;
		server 实际ip:8002;  
	}	

	## ip并发请求限制
#	limit_req_zone $binary_remote_addr zone=one:10m rate=50r/s;
#	limit_req_zone $server_name zone=perserver:10m rate=50r/s;
	
	## ip 连接数限制
#	limit_conn_zone $binary_remote_addr zone=addr:10m;
#	limit_conn_zone $server_name zone=perserverconn:10m;	
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值