记录一下又拍云图片迁移至腾讯云,nginx转发规则
location ~ "^(/.+?)(%21|!)/both/(\d+)x(\d+)$" {
# 优化正则:非贪婪匹配 + 支持编码
rewrite ^(/.+?)(%21|!)/both/(\d+)x(\d+)$ $1?imageMogr2/thumbnail/!$3x$4r/gravity/center/crop/$3x$4 break;
proxy_pass https://res.xxx.com;
proxy_set_header Host res.xxx.com;
# 保留其他proxy设置...
}
# 修改普通图片location:排除含!的请求
location ~ ^/.+?\.(jpg|jpeg|png|gif|webp|bmp)$ {
# 添加条件:不匹配含!或%21的URL
if ($request_uri ~ "(%21|!)") {
return 404; # 或跳过此location
}
proxy_pass https://res.xxx.com;
proxy_set_header Host res.xxx.com;
}
推荐文章: