1.创建oss的桶
设置成公共读
2.在服务器的nginx上面配置反向代理
一定对要写oss的内网地址:比如http://wltest1001.oss-cn-beijing-internal.aliyuncs.com【服务器和oss一定要在同第一地域否则内网不互通】
3.这个时候我们访问图片会提示下载,访问html也是下载,修改反向代理配置文件 (重点)隐藏OSS返回的Content-Disposition和Content-Type头
#PROXY-START/
location ^~ /
{
proxy_pass http://wltest1001.oss-cn-beijing-internal.aliyuncs.com;
proxy_set_header Host wltest1001.oss-cn-beijing-internal.aliyuncs.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
# 隐藏OSS返回的Content-Disposition和Content-Type头
proxy_hide_header Content-Disposition;
proxy_hide_header Content-Type;
# 添加新的Content-Disposition和Content-Type头
add_header Content-Disposition "inline";
}
#PROXY-END/