動(dòng)態(tài)圖片剪切
location ~/wx/storage/fetch/(.*) {?
? ? ? ? ? ? alias? /root/storage/$1;
? ? ? ? ? ?#? access_log off;
? ? ? ? ? ? # 圖片默認(rèn)寬度
? ? ? ? ? ? set $width -;?
? ? ? ? ? ? # 圖片默認(rèn)高度
? ? ? ? ? ? set $height -;?
? ? ? ? ? ? if ($arg_width != "") {
? ? ? ? ? ? set $width $arg_width;
? ? ? ? ? ? }?
? ? ? ? ? ? if ($arg_height != "") {
? ? ? ? ? ? set $height $arg_height;
? ? ? ? ? ? }?
? ? ? ? ? ? # 設(shè)置圖片寬高
? ? ? ? ? ? image_filter resize $width $height;?
? ? ? ? ? ? # 設(shè)置nginx讀取圖片最大buffer
? ? ? ? ? ? image_filter_buffer 5M;?
? ? ? ? ? ? # 是否開啟圖片隔行掃描? ? ? ? ? ? ? ?
? ? ? ? ? ? image_filter_interlace on;?
? ? ? ? ? ? error_page 404 = error.gif;
?}?
代理并限流
http {
limit_conn_zone $binary_remote_addr zone=perip:10m;? ? ? ??
limit_conn_zone $server_name zone=perserver:10m;?
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1000r/s; #表示每秒最多處理x個(gè)請求,請求限制?
# limit_conn_zone $binary_remote_addr zone=addr:10m; #對10m(16w個(gè)ip)來做限制,并發(fā)限制?
limit_conn_log_level error; #默認(rèn)
?limit_conn_status 503; #默認(rèn)??
}
location /litemall/ {?
? ? ? ? ? limit_req zone=mylimit burst=1000 nodelay; #請求限制?
? ? ? ? #? limit_conn addr 50;? #并發(fā)限制
? ? ? ? ? proxy_pass http://111.111.111.111:18080/;
? ? ? ? ?add_header Access-Control-Allow-Origin *; #即接受所有跨域的請求? ? ?
? ? ? ? ? #獲取用戶真實(shí)ip
? ? ? ? ? proxy_set_header? Host? ? ? ? ? ? $host;
? ? ? ? ?proxy_set_header? X-Real-IP? ? ? ? $remote_addr;? ?
? ? ? ? ?proxy_set_header? X-Forwarded-For? $proxy_add_x_forwarded_for;
}
HTTP
http {
deny 192.168.66.88;? #黑名單
keepalive_timeout 60; #不重新開啟tcp通道時(shí)間
access_log off;? #開啟日志
log_format??main '$remote_addr - $remote_user [$time_local]??'??
: '"$request" $status $bytes_sent '
: '"$http_referer" "$http_user_agent" "$request_time';
access_log /www/server/nginx/logs/nginx-access.log main;
}
重定向
重定向? ? ? ?
if(!-e $request_filename)? ? ? ? ?{ #如果請求匹配不存在則重定向
? ? ?rewrite? ^ /index.html? break;
? ? ?last?本條規(guī)則匹配完成后繼續(xù)向下匹配新的location URI規(guī)則
? ? ?break?本條規(guī)則匹配完成后終止缠借,不在匹配任何規(guī)則
}
訪問控制? ? ?
?? ? set $ip $remote_addr; #訪問控制? ? ?
? ? ? if($ip='192.168.1.106')? ? ? ? {? ? ??
? ? ? ????? return 444? "test";? ? ?
? ? ? }? ??
靜態(tài)資源
靜態(tài)文件
location /file/??{
alias?? D:/java/static/;
index??autoindex on;
}
靜態(tài)頁面
location /? ? ? ? ? {? ? ? ?
???root /java/static/dist/;? ? ??
? ?add_header Access-Control-Allow-Origin *; #即接受所有跨域的請求? ? ??
??}???