Nginx conf 配置文件
######################## default ############################
server {
listen 8067;
server_name _;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/default;
index index.html index.htm index.php;
#error_page 404 /404.html;
#error_page 502 /502.html;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location /img/ {
image_filter watermark;
image_filter_watermark "/usr/local/nginx/html/760.png"; #圖片水印路徑
image_filter_watermark_position center-center;
}
location ~* /img3/(.+)_(\d+)x(\d+)\.(jpg|gif|png)$ {
set $h $2;
set $w $3;
if ($h = "0") {
rewrite /img3/(.+)_(\d+)x(\d+)\.(jpg|gif|png)$ /img3/$1.$4 last;
}
if ($w = "0") {
rewrite /img3/(.+)_(\d+)x(\d+)\.(jpg|gif|png)$ /img3/$1.$4 last;
}
#根據(jù)給定的長寬生成縮略圖
image_filter resize $h $w;
#原圖最大2M,要裁剪的圖片超過2M返回415錯誤,需要調(diào)節(jié)參數(shù)image_filter_buffer
image_filter_buffer 4M;
image_filter_watermark_width_from 15; # Minimal width (after resize) of when to use watermark
image_filter_watermark_height_from 15; # Minimal height (after resize) of when to use watermark
image_filter_watermark "/usr/local/nginx/html/760.png";
image_filter_watermark_position center-center;
#error_page 415 /usr/local/nginx/html/760.png;
try_files /img3/$1.$4 /usr/local/nginx/html/760.png;
}
參考鏈接
阿里云:https://yq.aliyun.com/ziliao/29266
注意事項
root /data/testfile;
location /img/ {
#路徑中必須包含img文件夾,否則出現(xiàn)415 錯誤
#則必須存在的路徑為:/data/testfile/img/
}