阿里云对象存储OSS使用 HTTPS

2023-06-14,,

一、前言

  阿里对象存储oss本身也是可以用HTTPS直接访问的,但是它本身的地址是http://***.oss-cn-hangzhou.aliyuncs.com这样的,那么如果我们想使用自己的域名,并且HTTPS加密,实现,防钓鱼,防劫持,防篡改,如何实现呢?

二、域名解析

  2.1 oss本身域名: http://abc.oss-cn-hangzhou.aliyuncs.com

  2.2 自定义的域名: https://image.myname.com

  首先我们将 image.myname.com 解析到一个有公网ip阿里云ECS服务器上,阿里云上提供域名解析的服务

三、Nginx重定向

  vim oss.conf 

 server {
listen 80 ;
listern 443 ssl;
server_name image.myname.com;
access_log logs/oss_access.log;
error_log logs/oss_error.log;
ssl_certificate certs/_.***.crt;
ssl_certificate_key certs/_.***.key;
if ($scheme = http) {
return 301 https://$server_name$request_uri;
} loccation ~ /abc/ {
rewrite ^(.*)/(.*)$ http://abc.oss-cn-hangzhou.aliyuncs.com/$2 last;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

  

阿里云对象存储OSS使用 HTTPS的相关教程结束。

《阿里云对象存储OSS使用 HTTPS.doc》

下载本文的Word格式文档,以方便收藏与打印。