#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