目录
前言
云服务器用起来感觉最难受的就是带宽了,国内的云服务器普遍带宽都很小,但买国外或者香港的话延迟大还容易被封IP。一般网站/app最占带宽的是图片和音视频等文件的上传下载,下面我们要聊的cos和cdn就是解决这个问题来的。
简介
对象存储COS
- 对象存储不同于我们平时操作系统里的文件存储,它就像一个map,存储的所有文件都有一个唯一的名称作为key,文件内容作为value。而没有目录的概念。
- 这样做的意义在于,当文件很多,目录结构深时,文件存储需要根据那颗目录树一步一步找到文件,显然是比对象存储直接按文件名一步到位得到要来得慢。
- 但目前很多云服务厂商都有在对象存储上提供目录功能,这大多是模拟出来的。比如腾讯云是将文件名中的 / 识别为目录模拟得到的。
- 比如:放进两个文件:
- aaa.txt
- wow/abc.cpp
- 由于 "wow/abc.cpp" 的文件名带有 / ,则可以模拟解析为是放在wow目录下,存在一个文件叫abc.cpp。
- 我们使用云服务提供的COS来替换我们的服务器实现文件的上传和下载。一般云服务COS不限制下载速度,且用户上传也免费。但用户的下载流量、存储空间占用、请求次数是要收钱的。
- 注意这不是三选一的问题,是三个方面都要收钱的!
- 比如:在一个月的时间里,我们向COS上传了 100 MB 文件,发送过 1 w 次读写请求,且用户外网下载文件使用过 10G 的流量。
- 那么结算时,需要支付:A + B + C
- A:100M/1个月 的存储空间占用费用
- B:1w次读取请求费用
- C:外网下载 10 G 流量费用
- 显然,外网下载流量很容易被人攻击,盗刷流量,然后疯狂扣流量包扣费,容易出现一觉醒来,没了一套海景房的刺激。后面我们用CDN来防止一部分攻击,因为COS的流量费比CDN贵非常多,而且CDN能设置更多的访问限制,降低被攻击的损失,所以可以用CDN抗在前面。
CDN
- cdn的用途很广泛,由于用户在地域上分布全国甚至全球各地,而我们的服务器一般是只在一个或几个地方而已,cdn在地域上可以分散多个节点,作为一个中间人,缓存用户访问服务器上的文件,并在用户下一次请求这个文件时,cdn就可以直接提供给用户,而不需要大老远来请求服务器,提高用户的访问速度。
- 这里我们可以利用这个特性,且其价格低,来帮助COS降低被攻击的损失。
使用问题
盗刷COS流量
- 前面我们已经提到,COS的外网下载流量是比较贵的,而且速度快,容易被攻击刷流量。
- 解决办法:
- 把COS访问权限设置为 私有读私有写
- 当用户需要上传文件时,使用云厂商提供的SDK,服务端预签名上传文件的URL,并将签名后的链接发送给用户,客户端只能按照签名链接指定参数、请求头、请求类型的上传文件到COS,上传不需要使用CDN。
- 当用户需要下载时,使用SDK获取COS上对应文件名的文件链接,并将链接的域名替换为CDN的域名,然后返回替换后的链接给用户下载文件,并在CDN设置限制IP访问速度、下载速度等限制即可。
防盗链/限速
- 由于浏览器不允许伪造请求头中的Referer、Host、Origin,因此可以在CDN/COS都配置防盗链,限制请求的Referer。这个可以阻止别人的网站直接把你的资源链接放到他的网站使用的情况,减少一些被偷资源流量的问题,但他直接下载你的资源然后上传到他的服务器还是可以的。
- 注意网页是可以指定浏览器不携带Referer的,即请求是空Referer。而在浏览器直接敲网址进入网页时的请求也是空Referer,你需要考虑是否需要允许空Referer的请求。防盗链挡不住客户端请求,因为客户端是可以随意伪造请求中的任意值的。如APP、nodejs、命令行、服务端程序等,只要是非标准浏览器环境就可以随意伪造。
- 在CDN中,可以限制下载速度、IP访问速度等。
https网站中使用http资源
- 由于CDN的Https目前很多云厂商是收费的,虽然不贵,但也是钱。
- 如果你CDN访问使用了http,但网站是https协议时,直接在https网站里获取http资源(图片、音视频等)会被浏览器认为是不安全的,并在浏览器的开发者工具中打印警告,但也是能用的。但默认不会带上Referer,因此如果你设置了防盗链不允许空Referer的话,就有问题了,这个时候可以在网页的<head></head>中添加配置:<meta content="always" name="referrer" >,这样浏览器在获取Http资源时也会带上Referer了
- https网站中发起http请求是不允许的!
上传文件大小/数量限制
- 用户向我们的服务端申请用于上传文件的预签名URL时,需要携带参数:文件大小、文件MD5,然后我们可以指定该链接发送时必须携带:
- Content-Length=500
- x-cos-meta-md5: {文件md5值}
- 由此就可以防止用户拿到预签名URL后,上传了其他文件的问题
- 文件大小限制,就是在我们服务端给预签名URL时进行检查。
- 文件数量限制,可以将用户、IP获取上传链接时写入数据库记录,根据这个记录来设计用户上传文件的数量和总大小等。
腾讯云COS的SDK/c++
- 整了老半天,终于写好了cmakelist能编译运行release,但debug版一直找不到链接符号。
- 看了大概是因为他是SDK源码里有一个文件夹three-party存放了已经编译好的第三方依赖库,但这些库是release的,因此需要我们编译debug的依赖库。但我的项目里也依赖openssl,改来改去才能release,最终debug版放弃了。
- 后来开始用上go了,学1天然后上手引入他的sdk和框架开发完cos相关的接口。有c基础还是很快上手的。
Pay attention to the praise and compliments you are receiving.Do they feel genuine and personal to you,ラブドール エロ
Good Website, Continue the beneficial work.
thnx.
ekspresjaroslawski.pl
Awesome webpage you possess here.
https://warszawa24.ovh
ラブドール エロwith a knack for explaining how these innovations affect both creators and consumers.The site’s aesthetic is modern and easy to navigate,
Принимать финансовые решения может быть сложно. Но с нашим каталогом финансовых продуктов это стало проще, чем когда-либо!
займ под 0 процентов
Мы собрали все лучшие финансовые продукты в одном месте, чтобы вы могли легко сравнить их и найти те, которые подходят именно вам. Наши экспертные обзоры и рейтинги помогут вам принять обоснованное решение, соответствующее вашим уникальным потребностям.
Независимо от того, ищете ли вы кредит наличными, дебетовую карту или инвестиционный счет, наш каталог финансовых продуктов поможет вам сделать правильный выбор.
The very next time I read a blog, Hopefully it won’t disappoint me as much as this one. After all, I know it was my choice to read through, however I really thought you’d have something interesting to talk about. All I hear is a bunch of whining about something you could possibly fix if you were not too busy seeking attention.
Adresli Duman Dedektörü, yangın algılama sistemlerinin olduğu alanda yangından kaynaklı oluşan duman partiküllerini algılayarakl yangın sistemlerine bilgi gönderir. Ayrıca dedektörler adresli olduğundan dolayı da yangının nerede çıktığını nokta atışı tespit eder.
купить двухкомнатную квартиру https://kvartira-novostroyka2.ru
Passion the site– extremely user pleasant and whole lots to see!
https://www.oto-praca.pl
Заказать контрольную работу https://kontrolnye-reshim.ru, недорого, цены. Решение контрольных работ на заказ срочно.
Помощь в решении задач https://zadachireshaem-online.ru. Опытные авторы с профессиональной подготовкой окажут консультацию в решении задач на заказ недорого, быстро, качественно
Good post. I definitely appreciate this website. Keep it up!
Professional Frozen Yogurt Contractor Companies
Hotel Room Renovation Price
Obtain insights into hotel area restoration expenses with our thorough analysis. We aid you strategy and spending plan effectively for successful upgrades.
머니 마리아치(인니티니티 릴스)
황제 혼자서 세상의 모든 문제를 해결할 수는 없습니다.
купить 1 квартиру застройщика https://kvartiranovostroi2.ru
nor should your partner be expected to carry more than a fair share of the relationship and its obligations on their own.Quiet quitting a long-term relationship is not a new phenomenon,ラブドール 女性 用
купить квартиру в новостройке с ремонтом https://kvartira-novostroi.ru
when you don’t care or you just go along because that’s what you’re supposed to do.ラブドールStep back and now take a look at yourself.
000 times in scholarly publications.海外 セックスWilson’s concept certainly rings true to me.
Бесплатный сервис по подбору и ведению сделок с недвижимостью в новостройках Москвы и Московской области! Новые квартиры для жизни, дохода или инвестирования от топовых застройщиков с защитой государства подбор квартиры
купить квартиру новостройка застройщика отделкой https://zastroyshikekb.ru
недвижимость купить квартиру https://zastroyshikekb54.ru
квартира в новостройке от застройщика https://kvartiranovostroi.ru
Next time I read a blog, Hopefully it does not disappoint me as much as this particular one. I mean, I know it was my choice to read through, nonetheless I actually thought you would probably have something useful to talk about. All I hear is a bunch of crying about something you could fix if you were not too busy looking for attention.
It’s hard to find knowledgeable people in this particular subject, however, you sound like you know what you’re talking about! Thanks
אתה לא יודע על מה אנחנו מדברים – כדאי שתבוא לראות מה זה דירות דיסקרטיות בבאר שבע. זהו המקום החם ביותר בעיר. המקום שבו מבלים נמצאות בכל מקום, דירות דיסקרטיות בתל אביב גם מציעות חווית אירוח 24 שעות ביממה. כאשר אתה מרגיש חרמן בבוקרו של יום, או רוצה דירה דיסקרטית בבת ים
Sweet blog! I found it while surfing around
on Yahoo News. Do you have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Thanks
Coping with stress,loneliness,ダッチワイフ
https://medmens.ru
43.sex ドールLaughter comes easily around you.
This signal is itself so stressful that it can activate our own survival mechanism and add to the stress we carry.高級 ラブドールIt is natural of course to want to avoid discomfort,
It’s not easy to do but maybe it is a little bit easier to be vulnerable with someone who you’re not seeing and is not your regular therapist.More than once,人形 エロ
Здравствуйте!
Диплом вуза купить официально с упрощенным обучением в Москве
landik-diploms-srednee.ru/kupit-diplom-v-kazani В
квартиры от застройщика жк https://novyekvartiry2.ru
квартиру новостройку жк купить https://kvartirukupit43.ru
Привет, друзья!
Заказать документ университета
asxdiplomik24.ru/kupit-diplom-o-srednem-obrazovanii
купить 2 комнатную квартиру в новостройке https://newkvartiry-spb.ru
купить новостройку с ремонтом https://novye-kvartiry-spb.ru
купить однокомнатную квартиру недорогие квартиры от застройщика
Thank you for great article. Hello Administ .Seo Paketi Skype: By_uMuT@KRaLBenim.Com -_- live:by_umut
Добрый день!
Заказать диплом о высшем образовании.
blogs.rufox.ru/~sonnick84/48075.htm
amoxicillin 500 coupon: medicine amoxicillin 500 – amoxicillin capsule 500mg price
Remarkable issues here. I am very glad to see your article.
Thank you so much and I’m having a look forward to touch you.
Will you please drop me a e-mail?
buy generic ciprofloxacin: buy cipro online canada – buy cipro no rx
buy cipro without rx: buy cipro online – buy generic ciprofloxacin
Excellent article! We are linking to this particularly great post on our website. Keep up the good writing.
loneliness can be a profound issue. Sex dolls can offer a sense ofjydoll companionship and presence, helping to alleviate feelings of isolation.
Modern life and our eating practices can be demanding to our systems,
and if we don’t act, these stressors can take a toll on our bodies and minds.
So whether it’s an overload of chocolate from the Easter binge,
your office chair makes your back beg for mercy, or another long
day with the one in charge makes your head throb, standard Thai massage might be simply what you need.
The advantages of Thai massage might be really 21st century however they have their roots in ancient Eastern practices developed over thousands of years.
It’s all a long way from the experience you may have had of requirement, Westernised massage.
Performed on a special Thai mat in loose-fitting clothes, a therapist extends your
body through a series of techniques comparable
to yoga applies and postures pressure to particular points along the energy lines of your
body. Thai massage is excellent both physically and
psychologically.
It can increase flexibility, enhance muscle tone, increase movement, release
muscle stress, correct poor posture and fight stress.
How? Well, conventional specialists think that by assisting energy to stream easily around
the body once again they’re able to ease the symptoms of
persistent discomfort and improve psychological wellbeing.
A 2015 review of scientific trials found that
every released study reports benefits in post-treatment pain reduction. Some research
study concludes that standard Thai massage results in a reduction in discomfort of as much as
80% with the benefits kept for over 3 months at a time, consisting of
enhancements in muscle stress, versatility and even anxiety.
Findings published in the International Journal of
Neuroscience recommend that massage therapy has favorable impacts on the hormonal
agents and chemicals that regulate state of minds by decreasing cortisol and increasing both serotonin and dopamine.
This effective triple action can help in reducing depression and promote happiness.
Obviously, beyond the dry science, Thai yoga massage also simply feels actually, really nice.
Guided by an experienced therapist, purposeful extending combined with well-established pressure methods helps soothes
the muscles and enhance blood flow, leaving you relaxed and calm, ready to handle anything.
Welcome to pain and stress management, Thai-style. We welcome you to come in and experience the magic of a Thai yoga Massage on your own. To
reserve your Thai yoga massage at Castle Thai Spa, click here.
Body-to-body massage, also known as B2B massage, is a sensual
and intimate kind of massage that includes the use of not simply hands, however the whole body to offer relaxation and enjoyment.
In this post, we will explore the different elements of body-to-body massage, including its origins,
methods, benefits, and security precautions. Whether you are a
specialist or somebody thinking about experiencing this unique kind of massage, this post will offer you with valuable insights and
details. Let’s begin by acquiring a much deeper understanding of body-to-body massage.
This ancient practice has its roots in numerous cultures throughout
history. Body-to-body massage, also referred to as B2B massage, is a kind of massage that goes beyond the standard techniques.
It is an intimate and sensual experience that involves the close connection in between the
provider and receiver. Unlike other kinds of massage, B2B massage includes using numerous body parts, such
as the arms, chest, and legs, to provide a more immersive and satisfying
experience.
Body-to-body massage has been practiced for centuries in various parts of the world.
Its origins can be traced back to ancient Asian cultures, such as
India and China, where it was believed to enhance
spiritual and physical wellness. In these ancient customs, body-to-body massage was considered a holistic approach to healing and relaxation. In India, body-to-body massage was called “abhyanga,” which suggests “caring hands.”
It was a spiritual practice that was believed to balance the body’s energy and promote total wellness.
In China, body-to-body massage became part of the Taoist custom and was utilized
to promote the circulation of vital energy, known as “qi,” throughout the body.
Throughout history, body-to-body massage has actually evolved and
adapted to various cultures and societies. In some cultures, it was seen as a kind
of art and charm, while in others, it was considered a therapeutic practice.
Today, body-to-body massage is extensively recognized for its capability
to supply both psychological and physical benefits.
At its core, body-to-body massage includes the intimate connection in between the provider and receiver, developing a
sense of trust and intimacy.
The provider utilizes their body to apply pressure and perform numerous massage techniques on the receiver’s body.
During a body-to-body massage, the provider may use their arms to
glide efficiently over the receiver’s back, offering a peaceful
and calming experience. The chest might be utilized to use gentle pressure to particular locations, launching stress and promoting deep relaxation. The legs might be utilized to carry out extending motions, enhancing flexibility and increasing blood
circulation. One of the crucial concepts of
body-to-body massage is the focus on today minute.
Both the giver and receiver are motivated to be fully present and conscious of their feelings and bodies.
This mindfulness permits a much deeper connection and enhances
the overall experience. Another important concept
of body-to-body massage is interaction. The giver and receiver should honestly communicate their
choices, boundaries, and any pain they might experience during the
session. This guarantees that both parties are comfy and can fully take pleasure
in the experience. Overall, body-to-body massage is
an intimate and distinct practice that uses a variety of physical and psychological advantages.
The advantages of Thai massage may be really 21st century
however they have their roots in ancient Eastern practices established over thousands of
years. We invite you to come in and experience
the magic of a Thai yoga Massage for yourself.
Body-to-body massage, also known as B2B massage,
is a sensuous and intimate type of massage that
includes the use of not just hands, however the whole body
to supply relaxation and enjoyment. Body-to-body massage,
also known as B2B massage, is a kind of massage that goes beyond the conventional
techniques. The provider utilizes their body to use pressure and
perform numerous massage strategies on the receiver’s body.
性犯罪者を対象とする治療・社会復帰のために活用するなど、オナドールセックスロボットのポジティブな可能性についても検討されている。
allowing for a more personalized experienceirontech doll.