cdn概念
CDN通过广泛的网络节点分布,提供快速、稳定、安全、可编程的全球内容分发加速服务,支持将网站、音视频、下载等内容分发至接近用户的节点,使用户可就近取得所需内容,提高用户访问的响应速度和成功率(阿里云产品介绍)。
对于海外服务器,网上介绍的CDN服务商基本就cloudflare,imperva,和亚马逊的cloudfront。cloudfront支持S3存储桶和自定义源域名,配置起来也很方便。国内貌似也有支持CDN加速的服务商,不过节点可能没有那么多。
具体配置
登录AWS后,搜索CloudFront,进入CloudFront控制台。点‘创建分配’。

因为绝大部分都是Web方式,感觉步骤一就挺鸡肋的(根本没得选),点‘入门’直接到步骤二

这一页看起来配置很多,其实主要就两项(AWS的特色?):源域名,备用域名。
源域名
需要加速的源服务器的域名。注意。这个域名不能和提供给用户访问的自定义域名一样,原因参考这篇文章:AWS CloudFront / 亚马逊CDN使用教程 – 2206 – 博客园
有S3存储桶的直接在列表里选择,直接输入域名就是自定义的,路径非必选。


另外协议选了https或匹配查看器的话,源域名也要配置nginx的ssl证书
备用域名
如果需要通过自定义域名访问(如:http://res.example.com),就要填写备用域名,导入自定义ssl证书,或使用ACM公用证书。 这一步会将路由指向CloudFront生成的域名,还需再去route53配置CNames指向生成的dxxxxxxxxx.cloudfront.net

创建完毕后,也可以直接使用CloudFront随机生成的域名:dxxxxxxxxx.cloudfront.net
如果是用https访问,要选择自定义域名对应的ssl证书。
如果是网页应用,默认根对象(类似主页)也可以配置一下。

点击‘创建分配’,等到状态变为‘已部署’,就可使用CDN加速了。

验证效果
先向源服务器上传一张高清大图,然后用postman请求
未开启CDN加速:

开启CDN加速后:

也可以直接用浏览器验证,不过记得先清一下浏览器缓存,不然看不出效果
无CDN加速:

加速后:

查看ip地址,确实不再是从源服务器请求资源

总结
对于网站,音视频,下载类应用,CDN可以很好的提速,但是如果是提供api接口,逻辑算法类应用,CDN并不适用。
原文链接:https://blog.csdn.net/qq_42760638/article/details/116919205?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165918321816782388050817%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165918321816782388050817&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-12-116919205-null-null.nonecase&utm_term=cdn
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/168
评论列表(15条)
My spouse and I stumbled over here by a different website and thought I might check things
out. I like what I see so now i am following you. Look forward
to looking over your web page for a second time.
Hi Dear, are you actually visiting this web site on a regular basis,
if so after that you will absolutely get good experience.
What’s up i am kavin, its my first time to commenting anywhere, when i read this post i thought i
could also make comment due to this good paragraph.
This text is worth everyone’s attention. How can I find out more?
I am really thankful to the owner of this
web site who has shared this wonderful piece of writing
at at this place.
I will right away snatch your rss feed as I can’t to
find your email subscription hyperlink or newsletter
service. Do you have any? Please let me know so that I may just
subscribe. Thanks.
Excellent article. I’m going through a few of these issues
as well..
I don’t even know the way I stopped up right here, however I assumed this
publish was once good. I don’t know who you might be but definitely you’re going to a well-known blogger if you happen to aren’t already.
Cheers!
If some one wishes expert view regarding running a blog afterward i suggest him/her to
go to see this blog, Keep up the pleasant work.
whoah this blog is wonderful i like studying your articles.
Keep up the good work! You realize, many people are looking round for this information, you can aid them greatly.
What i do not realize is in fact how you are now not actually much more neatly-favored than you might be now.
You are very intelligent. You realize thus considerably when it comes to this matter, produced me in my opinion imagine it from a lot of varied angles.
Its like women and men don’t seem to be involved unless it is one thing to accomplish with
Lady gaga! Your personal stuffs excellent. All the time handle it up!
you are in point of fact a excellent webmaster.
The website loading pace is incredible. It kind of feels that you’re
doing any distinctive trick. Also, The contents are masterpiece.
you have done a great process in this matter!
Hello! This is my first visit to your blog! We are a group of
volunteers and starting a new project in a community in the
same niche. Your blog provided us valuable information to work on. You have done a outstanding job!
We are a group of volunteers and opening a new scheme in our community.
Your site offered us with valuable information to work on. You’ve done an impressive job and our whole community
will be thankful to you.
Great beat ! I wish to apprentice whilst you amend your website,
how can i subscribe for a weblog site? The account aided me a acceptable deal.
I have been tiny bit acquainted of this your broadcast offered bright clear idea