nginx配置一般优化参数


#user  nobody;

worker_processes  2;

# CPU亲和力,worker_processes最多开启8个,注意写法
worker_cpu_affinity 01 10;

worker_rlimit_nofile 65535;

error_log  logs/error.log error;

pid        logs/nginx.pid;


events {
    use epoll;
    worker_connections  65535;
    multi_accept off;
}


http {
    include       mime.types;
    default_type  text/html;

    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;
    server_tokens off;
    client_max_body_size 10m;

    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;

    server {
        listen       80;
        server_name  192.168.0.165;
        location / {
            root   html;
            index  index.html index.htm;
        }


        location ~* \.(js|css)$ {
            expires 7d;
            log_not_found off;
            access_log off;
        } 
        
        # 图片防盗链,ip换成网址,可以使用通配符
        location ~*^.+\.(jpg|gif|png|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar)$ {
            valid_referers noneblocked 192.168.0.165;
            if ( $invalid_referer ) {
                #return 302 http://www.benet.com/img/nolink.jpg;
                return 404;
                break;
            }
            access_log off;
        }
        
    }

}

转载于:https://www.cnblogs.com/sanduzxcvbnm/p/11314552.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值