nginx代理实现https访问阿里云oss资源
2022/4/30 7:13:09
本文主要是介绍nginx代理实现https访问阿里云oss资源,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
2022年4月29日
起因:买了阿里云的oss, 5年50块钱40G, 也够我自己用了,但是我自己的网站是https的,要想加载阿里云的oss图片资源也得是https的才行
方案一:阿里提供的https服务, 缺点太贵,
方案二:上传自己的证书, 缺点:太麻烦,我用的是免费的certbot, 每三个月会重新更新一次证书,也就需要重新上传到阿里云
方案三:用自己服务器上的nginx转发阿里云的资源 (推荐)
nginx server 配置:
1 server { 2 server_name static.xxx.xxx; 3 4 location /ali/ { 5 proxy_pass http://xxx.oss-cn-hangzhou-internal.aliyuncs.com/; 6 proxy_set_header Host "xxx.oss-cn-hangzhou-internal.aliyuncs.com"; 7 proxy_set_header X-real-ip $remote_addr; 8 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 9 proxy_hide_header Content-Disposition; #注意,这一句可以防止浏览器下载文件 10 } 11 }
这篇关于nginx代理实现https访问阿里云oss资源的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29fail2ban nginx
- 2024-03-18install nginx proxy manager
- 2024-01-2444从零开始用Rust编写nginx,命令行参数的设计与解析及说明
- 2024-01-22比Nginx更好用的Gateway!
- 2024-01-17nginx daemon off
- 2023-12-30Nginx Vhost Traffic Status 是什么意思-icode9专业技术文章分享
- 2023-12-26使用nginx搭建creates.io镜像(稀疏索引)
- 2023-11-18centos7编译安装Nginx教程。
- 2023-11-02nginx启动命令和停止命令
- 2023-10-25Centos7系统Nginx负载均衡如何安装和配置?