PHP菜鸟博客_共同学习分享PHP技术心得【PHP爱好者】
阿里云esc自建nginx反向代理到oss(走内网)搭建图床。
2024-11-27 菜鸟站长


1.创建oss的桶



设置成公共读



2.在服务器的nginx上面配置反向代理



1.png



一定对要写oss的内网地址:比如http://wltest1001.oss-cn-beijing-internal.aliyuncs.com【服务器和oss一定要在同第一地域否则内网不互通】



3.这个时候我们访问图片会提示下载,访问html也是下载,修改反向代理配置文件 (重点)隐藏OSS返回的Content-Disposition和Content-Type头







2.png



8888.png






#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/




发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容