配置如下
location ^~ /oss/ {
if ( $request_uri ~* \.(png|jpg|jpeg) ){
set $args "x-oss-process=style/watermark";
}
proxy_pass http://<bucket>.oss-cn-beijing-internal.aliyuncs.com/;
proxy_set_header Host <bucket>.oss-cn-beijing-internal.aliyuncs.com;
proxy_hide_header Content-Disposition;
}
如果匹配不到,请检查:
- 文件是否存在
- 阿里云oss是否配置外网访问
- 注意nginx优先级
通过ECS中Nginx反向代理到阿里云OSS内网,浏览器直接显示图片和文本
nginx路由location匹配规则及其优先级