No copy
Forward
Back
reload
;Message
首页
💼工作
🔧机械 ♑ 液压
✈ 航空相关
📏仪表及电气
⏳ 阀门相关
⛹️♀️生活
📽️影音相关
👀我看...
♪ 我听...
🗑️其他
🚴♀️游记
关于...
友链
统计
更多...
XC'S 图册
XC'S视频
单位转换
Search
1
小米11 Ultra 刷机rom、面具magisk、太极.阳折腾记
15,983 阅读
2
Apache & PHP 8.0.X 分享Apache80_2454.8210_arm_64.qpkg
8,598 阅读
3
Solidworks 2016 激活Activator.GUI.SSQ产生的卡顿 闪退
7,764 阅读
4
电液伺服阀特性参数、定义、技术术语,如何测试操作。
6,807 阅读
5
NAS黑群晖DSM7.0 定时开关机方案
6,083 阅读
登录
/
注册
Search
标签搜索
培训学习
xc影后感
想说两句
软件分享
液压经验
心灵感悟
液压产品样册
行业知识
AMESIM
试验台
影评
测试设备
测试内容与方法
生活小技巧
生活感言
仪表产品样册
追忆少年
3D模型
typecho
经验
xc
累计撰写
218
篇文章
累计收到
906
条评论
首页
栏目
💼工作
🔧机械 ♑ 液压
✈ 航空相关
📏仪表及电气
⏳ 阀门相关
⛹️♀️生活
📽️影音相关
👀我看...
♪ 我听...
🗑️其他
🚴♀️游记
页面
关于...
友链
统计
XC'S 图册
XC'S视频
推荐
单位转换
最新回复
123
2024-10-17
匆匆过客
123123
sdaf
2024-10-13
匆匆过客
?
openwrt
2024-09-20
匆匆过客
管住嘴,迈开腿
搜索到
218
篇与
的结果
2024-10-19
solidworks 零件属性和工程图图框数据关联,以及装配图bom清单的生成
概述最近工作需要,涉及到工程图规范化的问题,用了两天的时间研究了一下solidworks的工程图相关用法,特此分享,顺便也记录一下。我们用软件制图的时候,前期尽可能的把各个数据都录进去,这样在出工程图或装配图的时候,就非常便捷,可以说是一键生成。正文零件设计公差的数据一切的根源都是零件设计,3D模型设计的时候,最好就需要录入公差,并且规范操作,找好对应的基准做尺寸限制,这样在工程图中就可以自动生成尺寸:零件属性菜单制作零件的属性可以点击“文件属性”按钮打开:可以看到我这里已经录入了部分数据在自定义属性,其实旁边的“配置属性”和自定义属性功能都差不多,但它的优先级会更高,功能更多,比如利用数据表驱动零件的设计尺寸,批量生成多种同类产品或图纸,我们这里只想影响工程图的一些显示信息,我就用在自定义属性了。当然,这里你可以把信息手敲进去,便于后面工程图的调用,不过,还有一个更好的办法,就是自定义一个属性录入菜单。更直观便捷一些。上面这个是我自定义好的菜单,每个零部件都可以通过它快速便捷的录入基础信息,是不是也想要,下面附件可以直接下载我目前设置好的文件,也可以自己动手来配置。如果是用我目前配置好的文件,请直接跳过点击右下角的按钮,打开模板选项对话框:这里显示了菜单文件的位置和编辑程序,打开编辑程序其实,还是很简单,1、2、3 一共3列,第1列主要是编辑菜单所用的部件或控件,按需选择在第2列,第3列主要是各个控件的属性修改,相信你琢磨一下,很快就能上手。需要说明的是:序号4 是数据传递的函数名称,不要重名,序号5和6 其实就分别对应了上面提到的“自定义属性”和“配置属性”,看你是打算保存在哪个位置。编辑好,保存好位置,建议利用solidworks的默认位置,这样打开就很容易调用,在这里查看:当然,你也可以自定义位置。工程图配置我们需要编写自己公司的工程图图框,然后把数据链接在一起,这样,当导入模型文件的时候,这些信息将会自动被填写。是不是非常便捷?当然,你可以用我上面的菜单文件,要可以用我这里的工程图模板,这样是匹配的,可以直接达到上面的效果。关联数据通过鼠标点选如果你想自定义图框,并关联数据,可以按照以下操作。默认是工程图的属性,如果和模型本身的一些属性有关,可以选择下面的那个选项。通过编辑传递函数另一个方法就是直接编辑传递的函数名称,确保文件属性有对应的选项,然后直接编辑同样的名称,即可调用。装配图bom最后讲讲装配图的bom表单生成问题,solidworks自带了一些材料bom格式的表格,但每个公司多少都有一些差异,就像我们公司用的就是这种样式。我这里已经编辑好了,你可以直接拿来用,用法如下:表格如果很短,就可以直接插入在装配图中,如果bom清单较多,建议导出为excel进行编辑保存。如果你的格式和我差不多,可以在我这个基础上进行更改,但如果想自己编辑自己的格式,可以在solidworks自带的bom表格中,自行设计,数据的引用可以双击顶行的A、B...来选择关联数据。附件:XC工程图A4.DRWDOTXC装配图属性.asmprpXC材料明细.sldbomtbtXC零件属性.prtprp隐藏内容,请前往内页查看详情
2024年10月19日
4 阅读
0 评论
0 点赞
2024-09-12
用SOLIDWORKS Flow Simulation 液体搅拌仿真
概述最近对仿真又有点兴趣了,原本打算学习ANSYS的,但仔细分析发现,ANSYS的仿真建模有点奇怪,对我习惯了用solidworks的用户来说,SOLIDWORKS自带的Flow Simulation 岂不是更香?在学习的路上,碰到了一个案例:在一个水缸中,又两种液体,上下分层,我们要搅拌它,看看他们混合的状态过程和搅拌叶轮所产生的扭矩变化。挺有意思,特此记录。仿真结果说明:红色和蓝色是两种液体,仿真了搅拌从0秒-5秒的混合变化,转速120rpm.仿真方法水缸的结构尺寸:直径1.22米, 深度1.22米实体搭建需要依次绘制出:缸体、盖子、叶轮、水和旋转区域零部件零部件 开始仿真旋转时长0-5s,增加重力隐藏内容,请前往内页查看详情扭矩值
2024年09月12日
2 阅读
0 评论
0 点赞
2024-07-04
孔径流量压损三者关系的有效范围,超出后,流量将不再随着压力的增大而增大
概述前两天,好友再次和我讨论起流体系统中,孔径、流量、压损三者的关系,一个实际的案例中,当压力足够大时,发现按照我分享的公式,计算出来的流量超级大,不由的怀疑结果的准确性。参考: 孔径.流量.压差计算.xlsx 计算工具分享 我也不由的进行了思考,我上面的公式就没有限制吗?举个形象点的例子,就像一个水库的大坝,下面开了一个很小的孔,随着水位的上升,水压逐渐增大,但流量不会无限增大,喷射的液体距离也是有限范围内。正文我开始搜索这个现象的答案,看看ChatGTP的回答:问题1:流量会随着压损的上升无限增大吗?流体系统中,压力源如果无限大,忽略管道其他压力损失,流量会随着压力的增大,无限增大吗?在假设压力源无限大且忽略管道其他压力损失的情况下,流量不会无限增大。这是因为流体系统中还有其他因素会限制流量的增加,即使压力源能够提供无限的压力。主要因素包括:孔径的物理限制:流体系统中的孔径(例如喷嘴或阀门的开口)是固定的。根据伯努利方程和流体力学理论,当孔径固定时,流量 其中,𝐶𝑑是流量系数(通常由实验测得),无量纲,A 是孔径面积,单位为 ㎡ρ 是流体密度,单位为 kg/ m³音速限制:对于流体系统中的液体,当流体速度接近液体的音速时(即发生气蚀或空化现象),流量会受到限制。液体中的音速限制了流体速度的最大值,因此流量也不会无限增大。系统的结构强度:流体系统的管道、接头和其他元件都有其结构强度极限。如果压力无限增大,系统的物理结构可能会承受不住,导致损坏或破裂。流体的粘性和湍流效应:随着流量增加,流体的粘性和湍流效应会导致更高的能量损失,即使忽略管道的其他压力损失,流体本身的特性也会限制流量的无限增大。综上所述,即使压力源可以提供无限大的压力,流量也不会随着压力的增大而无限增大,因为孔径的物理限制、音速限制、系统的结构强度以及流体的粘性和湍流效应等因素都会限制流量的进一步增加。问题2:如何计算这个临界值?要计算流体系统中流量不再随压差增大而增加的临界值,需要考虑以下几个关键因素:孔径、流体性质和系统配置等。孔径和流量的基本关系 参考上面的公式。音速限制 液体中的音速限制了流体速度的最大值。当流速达到或接近液体中的音速时,气蚀或空化现象会发生。这是临界流速(音速)的一种限制情况。对于液体,音速 c 可以表示为:其中:𝐾 是液体的体积弹性模量,单位为帕斯卡(Pa)计算临界流量为了确定流量不再随压差增大而增加的临界值,我们需要找到临界流速 𝑣𝑐并将其转换为流量 𝑄𝑐。首先,假设临界流速 𝑣𝑐接近液体的音速 𝑐:然后,临界流量 𝑄𝑐 可以通过孔径面积和临界流速计算得到:实际计算步骤确定流体的性质:获取流体的密度 𝜌和体积弹性模量 𝐾。计算音速确定孔径面积𝐴:根据孔径直径 𝑑计算孔径面积:计算临界流量 示例计算假设使用的液体是水,其密度 𝜌为 1000 kg/m³,体积弹性模量 𝐾为 2.2 GPa(即 2.2 × 10^9 Pa),孔径直径 𝑑为 0.01 m。计算音速 计算孔径面积 计算临界流量 因此,在这种情况下,流量的临界值约为 0.116 立方米每秒,当压差进一步增加时,流量不会显著增加。AI总结通过上述步骤,可以计算出流体系统中流量不再随压差增大而增加的临界值。实际应用中还需考虑其他因素如系统设计、材料特性等来调整计算模型。我的总结从AI的回答中,我认为理论上是正确的,但这一结果还需要进一步实验验证,我后续会找机会来进一步取证,跟踪更新本文章。当然也可以用仿真软件来初步判断,有空的时候。
2024年07月04日
4 阅读
0 评论
1 点赞
2024-06-24
利用ffmpeg 将3D视频上下格式,左右格式转换为2D格式正常视频
概述现在3D视频资源不多,虽然体感是不错,但穿戴麻烦,片源太大,在加上3DVR格式的加持,这东西半死不活,我有一个3D头盔,刚拿到手完了一段时间,现在一直在吃灰中。手上有个三星公司出的3D视频,也是多年前从互联网下载的MTV,韩国男女团现场演唱会,很精彩,今天忽然想,要是能分享在我的视频页面就好了。我的视频资源是上下格式的,在网上找以下资料,还是ffmpeg强大,原理到也简单,只保留左眼或右眼的视频,再调整一下画面比例就OK了。正文上下/左右3D格式分离为2D正常视频下面的代码是上下格式分离为正常的2D视频代码:相关的代码说明 stereo3d 最核心的代码就是:abl:ml分离后,视频比例一般会失衡。所以用“-aspect 16:9”来调整视频画面比例,最后用“-vcodec h264” 编码转换为mp4格式。请根据自身情况,灵活调整。上下格式代码ffmpeg -i A.mkv -vf stereo3d=abl:ml -metadata:s:v:0 stereo_mode="mono" -aspect 16:9 -vcodec h264 B.mp4左右格式代码ffmpeg -i A.mkv -vf stereo3d=sbsl:ml -metadata:s:v:0 stereo_mode="mono" -aspect 16:9 -vcodec h264 B.mp4这里copy一份stereo3d的官网内容,便于查询修改:stereo3dConvert between different stereoscopic image formats.The filters accept the following options:inSet stereoscopic image format of input.Available values for input image formats are:‘sbsl’side by side parallel (left eye left, right eye right)‘sbsr’side by side crosseye (right eye left, left eye right)‘sbs2l’side by side parallel with half width resolution (left eye left, right eye right)‘sbs2r’side by side crosseye with half width resolution (right eye left, left eye right)‘abl’‘tbl’above-below (left eye above, right eye below)‘abr’‘tbr’above-below (right eye above, left eye below)‘ab2l’‘tb2l’above-below with half height resolution (left eye above, right eye below)‘ab2r’‘tb2r’above-below with half height resolution (right eye above, left eye below)‘al’alternating frames (left eye first, right eye second)‘ar’alternating frames (right eye first, left eye second)‘irl’interleaved rows (left eye has top row, right eye starts on next row)‘irr’interleaved rows (right eye has top row, left eye starts on next row)‘icl’interleaved columns, left eye first‘icr’interleaved columns, right eye firstDefault value is ‘sbsl’.outSet stereoscopic image format of output.‘sbsl’side by side parallel (left eye left, right eye right)‘sbsr’side by side crosseye (right eye left, left eye right)‘sbs2l’side by side parallel with half width resolution (left eye left, right eye right)‘sbs2r’side by side crosseye with half width resolution (right eye left, left eye right)‘abl’‘tbl’above-below (left eye above, right eye below)‘abr’‘tbr’above-below (right eye above, left eye below)‘ab2l’‘tb2l’above-below with half height resolution (left eye above, right eye below)‘ab2r’‘tb2r’above-below with half height resolution (right eye above, left eye below)‘al’alternating frames (left eye first, right eye second)‘ar’alternating frames (right eye first, left eye second)‘irl’interleaved rows (left eye has top row, right eye starts on next row)‘irr’interleaved rows (right eye has top row, left eye starts on next row)‘arbg’anaglyph red/blue gray (red filter on left eye, blue filter on right eye)‘argg’anaglyph red/green gray (red filter on left eye, green filter on right eye)‘arcg’anaglyph red/cyan gray (red filter on left eye, cyan filter on right eye)‘arch’anaglyph red/cyan half colored (red filter on left eye, cyan filter on right eye)‘arcc’anaglyph red/cyan color (red filter on left eye, cyan filter on right eye)‘arcd’anaglyph red/cyan color optimized with the least squares projection of dubois (red filter on left eye, cyan filter on right eye)‘agmg’anaglyph green/magenta gray (green filter on left eye, magenta filter on right eye)‘agmh’anaglyph green/magenta half colored (green filter on left eye, magenta filter on right eye)‘agmc’anaglyph green/magenta colored (green filter on left eye, magenta filter on right eye)‘agmd’anaglyph green/magenta color optimized with the least squares projection of dubois (green filter on left eye, magenta filter on right eye)‘aybg’anaglyph yellow/blue gray (yellow filter on left eye, blue filter on right eye)‘aybh’anaglyph yellow/blue half colored (yellow filter on left eye, blue filter on right eye)‘aybc’anaglyph yellow/blue colored (yellow filter on left eye, blue filter on right eye)‘aybd’anaglyph yellow/blue color optimized with the least squares projection of dubois (yellow filter on left eye, blue filter on right eye)‘ml’mono output (left eye only)‘mr’mono output (right eye only)‘chl’checkerboard, left eye first‘chr’checkerboard, right eye first‘icl’interleaved columns, left eye first‘icr’interleaved columns, right eye first‘hdmi’HDMI frame packDefault value is ‘arcd’.结尾最终的效果,可以看我的视频页面-韩流来袭:oh!-Girls Generationoh!-Girls Generationsorry.sorry-Super Juniorsorry.sorry-Super Junior是否很棒?ffmpeg的更多用法,我已整理在一起了,请参考: 如何利用ffmpeg完成MKV转换MP4的视频格式,视频转gif图片格式。
2024年06月24日
31 阅读
0 评论
0 点赞
2024-06-18
typecho,腾讯云 cdn后,获取用户真实IP,回源HTTP请求头配置
概述网站评论区增加了用户Ip后,就没怎么关注了,直到这几天,回复留言时,发现Ip莫名的显示:湖南?我明明在成都的嘛,偏差这么大吗?赶紧翻阅了我近期的几条留言,都不正确,要么在湖南,要么就在陕西咸阳?查阅了网上的解释,那都是cdn搞的鬼,显示的是cdn节点的ip,网上当然给了解决方案:在配置文件 (/config.inc.php) 中加入如下配置。/** 定义 IP 来源 */ define('__TYPECHO_IP_SOURCE__', 'HTTP_X_FORWARDED_FOR');或者是://防止 CDN 造成无法获取客户真实 IP 地址 if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['REMOTE_ADDR'] = $list[0]; }但是,我参考并且照做了,结果没有用。不过,经过了好几个小时的折腾,其中这篇文章: Typecho 使用 CDN 后获取访客真 IP 给了我较大的帮助,当然,也引发了新问题,就是作者可以在服务器打印内容找到ip:HTTP_CF_CONNECTING_IP但是我打印出来没有啊。只能找到一个腾讯云的[HTTP_X_FORWARD_PORT] => 3944, 但看不到HTTP_X_FORWARD的地址。几乎要崩溃,最终还是联系了腾讯云支持工单,来回沟通,加上自行摸索,总算搞定,特此分享出来。查询自己的ip随便一个ip查询网站,查询自己的当前ip信息,看看是否正确,原作者采用的是 这里 ,那就用这个吧,只要和你的位置信息对的上,都行。打印自己的服务器信息新建一个 PHP 文件,输入以下内容PHP <?php print_r($_SERVER); ?>上传到服务器,然后通过浏览器访问,得到一堆内容。比对IP看看这对内容中,有没有自己的真是Ip,有的话,恭喜你,省事了,找出Ip 对应的代码,比如原作者找出的是:HTTP_CF_CONNECTING_IP修改config.inc.php然后在在配置文件 (/config.inc.php) 中加入如下配置。/** 定义 IP 来源 */ define('__TYPECHO_IP_SOURCE__', 'CF_CONNECTING_IP');//去掉HTTP_{callout color="#f0ad4e"}再次提醒://去掉HTTP_{/callout}没有找出ip我的是腾讯云cdn,请到这里,照抄,别问我是啥意思,我也不懂,抄就是了:再次对比ip不出意外的话,你应该是能找到一致的ip了,对应的代码是不是:HTTP_X_FORWARD_FOR然后修改config.inc.php/** 定义 IP 来源 */ define('__TYPECHO_IP_SOURCE__', 'X_FORWARD_FOR');//去掉HTTP_搞定,GOOD LUCK!
2024年06月18日
6 阅读
0 评论
0 点赞
2024-06-04
传感器输出信号是1-4.8V 但采集模块只有0-5V,怎么换算?
概述最近遇到一个传感器采集的问题:传感器输出信号是1-4.8V 但采集模块只有0-5V,确保他们是线性关系,如何换算呢?正文脑海里自然就想到了一次曲线的样子,知道两点,求其它点。用笔瞄了半天,还是小姐姐厉害,几下就把图发给我了,初中数学,好久不用,生疏了。图示解读压力传感器输出信号:1-4.8V传感器量程:0-2MPa采集模块对应模拟量是:0-5V计算结果采集模块对应物理量:-0.526~2.11 MPa图示解读位移传感器输出信号:1-4.8V传感器量程:0-50mm采集模块对应模拟量是:0-5V计算结果采集模块对应物理量:-13.12~52.66 MPa
2024年06月04日
12 阅读
0 评论
0 点赞
2024-06-04
lucky 的ssl证书申请,解决:acme: error: 400... DNS problem: server failure at resolver looking up TXT for _acme-challenge
概述我使用的域名昨天ssl到期了,今天打开后竟然是:竟然还不能直接访问http,赶紧用局域网登录lucky,发现ssl证书已经过去,并且自动申请没成功,我手动申请,也被拒绝,看日志:正文我网上学习了以下,大概了解到Let’s Encrypt 的验证方式包含了HTTP-01 验证 和DNS-01 验证 感兴趣的在这里看看。 Let’s Encrypt验证报错现象日志很明显提到了DNS验证出错,大概意思就是说,查不到“_acme-challenge.xcshare.top” 这条域名的txt的记录值,(xcshare.top 是我的主域名): acme: error: 400 :: urn:ietf:params:acme:error:dns :: DNS problem: server failure at resolver looking up TXT for _acme-challenge.xcshare.top卡住问题当然还是搜索,发现老外的网站也是又这个问题,但他们就是在域名下添加txt记录,但我的问题是,txt的内容是怎么来的?我从哪里才能搞到txt记录呢?尝试解决既然找不到,干脆就用别人的值试试,它这个的本意就是验证域名所有权的问题,应该不存在唯一性的问题吧,结果竟然解决了,很幸运。所以,我觉得有必要分享出来,给同样出问题的同学们!正确的做法到你们的域名服务商,添加一条或两条txt记录, 因我我申请的是两个域名的:xcshare.top*.xcshare.top你如果是申请的一个域名的,那添加一条记录即可,详细看你日志的报错信息。结尾上内容:二级域名(注意前面不要有空格) _acme-challenge txt记录值内容 glTMop6r8C8IUzeXqCm6qQq_tCE1_su2qFqO_nkOo8smo8efpFyr2YZIJpyRfc5KCDPd1rkch9cWXTzVa2In8g 是不是成功了,good lucky!
2024年06月04日
69 阅读
0 评论
0 点赞
2024-05-29
我看《活着》1994
概述看短视频介绍,知道了1994年《活着》的电影,葛优、巩俐主演,其实就是电视剧《福贵》的电影版,但为啥导演没有采用福贵的名字,而是取名“活着”。因为这两个字更符合电影的主题,也是福贵本人一生中最重要的意义。以前还觉得张艺谋老师的电影风格不是我喜欢的菜,但随着年龄的增长,越来越喜欢他的这些老电影了,这些电影中,可以看到那个淳朴的年代记事,至少,当做记录片看,还是很不错的。还有 《秋菊打官司》 正文电影呢,还是推荐大家自行找资源看一下,福贵的一生是相当折腾,但说实话,放到现在,还真是一部励志电影,如今,我们的生活好了,但生活压力大,很多人尤其是年轻的一代,碰到生活压力,一时解决不了,就想到了死。看看福贵的一生,那不得好死几回哦?好好活着,比什么都重要,活着就有无限可能,一个人的生命,在这个庞大的社会中,是非常渺小的,很多时候,我们的命运,完全是靠社会局势主宰的.活着,就像一张入场券,就像一张彩票,就像一盘赌局的赌资。。。也许,最终的结局依然是一无所获,但至少-你是有翻盘的机会;这部电影中穿插了一段戏剧性的一段:福贵的女儿要生孩子了,结果,技术专业性很强的大夫却被“打倒”了,关进了羊圈,三天不给食物,饿的有气无力。幸好,女婿有点小权利,把专家从羊圈弄出来,站在医院旁边,备用。结果。福贵两口子心善,看到专家太饿了,就让福贵去买点吃的,福贵也是太实在了,一次性买了8个馒头,专家长时间没进食,一口气干掉8个馒头,撑晕了,倒在地上。结果,好巧不巧,福贵女人产后大出血,医院一群学生娃吓得手忙脚乱,但资历最深的专家,晕倒在医院走廊。。。这一段,我刚开始看笑了,但看着看着看哭了。。。结尾电影被禁的原因,互联网上写的是:由于内容太过真实。回复应该算是比较委婉的,文化大革命时期,是我们都不愿提及的一段近代史,过去终究是过去了,活好当下,才是我们目前最应考虑的事情!
2024年05月29日
16 阅读
0 评论
0 点赞
2024-04-23
仪表模拟量对应物理量换算,Excel表格
简述工作中会经常使用仪表,模拟量输出自然也是经常选择的功能,最常用的还是:4-20mA的输出信号。以前是全部交给电气工程师搞定的,要么软件,要么PLC。。。今天现场条件不具备,临时用万用表测了一个仪表的反馈值:5.38mA, 仪表是个流量计,量程是16.7-166.7 LPM, 但实际流量是多少呢?原本以为很简单,仔细用笔一算,发现要梳理半天,索性交给AI帮我算一下吧?计算过程为了计算流量,我们首先需要知道流量量程和输出电流范围之间的关系。通常情况下,这种关系可以表示为某种形式的数学函数,比如线性函数。利用图像来表示:参数解释有效段:最大值-最小值物理量的有效段/模拟量的有效段 =a物理量的起始截距 =b需求物理量表示为:Q反馈模拟量表示为: c就可以利用公式:Q=c*a-|b|附件我已经整理好了公式在excel中,下载直接使用即可!隐藏内容,请前往内页查看详情
2024年04月23日
21 阅读
2 评论
0 点赞
2024-04-20
针对腾讯云内容分发CDN的设置,避免无法登录或登录状态不能更新的问题
概述这段时间使用到了一些云资源,比如cdn和对象存储功能。1.对象存储主要解决网站图片资源的放置和管理,其实就是图床功能。2.cdn 当然是加速网站访问速度,多人,多地域访问的请求响应问题,缓解了服务器请求频次和流量等问题。以上解释是我个人的理解,具体还请自行搜索了解,我这里只谈我使用中遇到的问题。我使用cdn的时候,网站的后台登录来时不能传递给前台,也算是折腾了很久。才总算解决,特此记录一下,同时供参考:开始设置(一)基础配置1.基本信息基本信息是在创建cdn时,根据实际情况填写。2.源站信息源站的意识是如果缓存不存在,去哪里“要数据”这里的源站不能使用加速的域名(会出现死循环)。为了方便,直接写服务的ip+443端口即可,或者是一个域名,这个域名指向源服务器所在ip。(二)访问控制这一项,我的实际设置基本都没内容,只有IP访问限频配置设置了:130,这个看自己需要.但下面还是顺便解释一下意义,便于理解设置。1.防盗链配置放盗链不能防止别人获取信息,只能阻止那些用你的资源显示别人网页的行为。(常见的有链接盗图,图片流量从你这走,但是是别人的网页)建议使用白名单模式,允许空referer访问(如果不允许空referer访问,无法输入url地址访问,会直接返回403)注意,如果你的应用需要调用外部的服务进行跳转,把这个外部服务的网址也加进来,否则无法跳转。2.IP黑白名单配置(默认无需配置)有如下情况需要配置,包括但不限于:(1) 受到指定ip的攻击,加入黑名单(2) 只允许白名单内的ip使用3.IP访问限频配置防止一些网络攻击,推荐开启,根据应用类型配置,如果不知道设置qps多少,可以使用100。然后后台统计大多数人具体的访问量,来进行调整即可如果设置过小,影响正常使用,网页加载文件不能全部载入,会报513的错误,如果过大,这个值设置就没有意义了。4.鉴权配置鉴权配置的意义在于,可以后端控制用户获取静态资源,即使用户知道文件位置,如果鉴权不通过,也无法从cdn获取。根据需要配置。有多种鉴权方式,一种是用算法时间鉴权,类似jwt,一种是转发到你的服务器进行验证(至于怎么验证则是后端的设计了)5.UA黑白名单配置添加对指定请求头的控制,通常是君子协议,因为请求头可以改。(但是大多数普通用户不会改的,所以还是过滤小白的操作)6.下行限速配置根据你的应用实际情况配置,为了限制具体的某个文件用户获取的速度。通常用于高流量的场景,可以不配置,等需要了再配置。7.访问端口配置保持默认,开启80和4438.区域访问控制插件建议开启,如果只面向国内用户,建议开启只允许国内ip访问9.远程鉴权需要自己搭建鉴权的服务器,有需要配置(需要后端开发支持),如果不熟悉,直接默认不开启。(三)缓存配置重点内容1.缓存键规则配置2.节点缓存过期配置重点配置区域(1) 全部文件,不缓存:(这个非常重要,很可能会导致后台正常登陆,但前台状态更新不及时的情况,这个问题困扰我很久,最终还是腾讯云的客服帮忙排查出的)(2) /usr/uploads,缓存10天。(这个文件夹大多是图片或附件,所以这里选择了,下面的文件后缀名,我就没有再增加图片格式了)(3) svg;woff;ttf;woff2;css;js,缓存2小时,根据自己情况调整。{callout color="#f0ad4e"}注意规则权限:新增加的权限越大,优先级就越高。如果不懂,就抄我的图。{/callout}给出我定义的内容,便于你懒得打字输入:/usr/uploadssvg;woff;ttf;woff2;css;js3.浏览器缓存过期配置保持默认即可,需要前端开发时去做,建议保持默认或者根据需要。4.状态码缓存保持默认404,如果需要返回别的状态,根据需要调整。5.HTTP头部缓存配置建议开启,方便开发和应用6.访问URL重写配置重写url可以在cdn配置,也可以在服务器入口处配置,根据需要配置。我的做法通常是不在cdn配置,即这里是无规则的。(四)回源配置重点内容1.合并回源配置建议开启即可2.分片回源配置通常不建议开启,容易出小问题3.回源HTTP请求头配置重点配置强烈建议开启,增加X-Forward-Port请求头获取真实ip原因是将ip写入请求头,就不用专门把ip一层层传递了,后端直接就可以从请求头获取。{callout color="#f0ad4e"}注意:目前的配置,网站获取是cdn节点的Ip,如果需要用户真实ip ,请参考: typecho,腾讯云 cdn后,获取用户真实IP,回源HTTP请求头配置 {/callout}4.回源跟随301/302配置建议开启,简单说就是你的外链也进行缓存,我的设置为不开启。5.回源超时配置保持默认配置6.回源URL重写配置根据情况,一般情况默认即可。这个配置同样可以在后端服务器配置,我的习惯是在后端服务器配置。把除了必须暴露外部的目录之外的其它全部屏蔽并指向404(后端的结构很重要)7.回源SNI配置保持默认关闭只有在一个ip绑定了多个域名时才需要配置注:一个ip绑定多个域名要额外加入反向代理或路由才能实现(五)https配置https是重点配置区域,稍有不慎就会无法访问,建议一定要用https1.HTTPS服务重点配置强烈建议开启,不建议使用http,建议全部https2.HTTPS配置重点配置务必上传域名的证书(https证书),否则会提示中间人攻击,直接无法访问注意:需要手动将https证书(ssl)的公钥和私钥内容复制到如下指定位置,自己生成的不行3.HTTP 2.0配置开启4.强制跳转建议开启,通常情况下,后端的服务器应该也增加跳转或者直接关闭http的访问(只允许https)、http->https,302,不携带头部(选择不携带头部,如果正常请求都是https,用http访问显然是为了试探)5.HSTS配置建议保持默认关闭6.TLS版本配置保持默认7.OCSP装订配置建议开启8.QUIC保持默认关闭,有需要也可以额外付费用(六)高级配置1.自定义错误页面配置如果请求不到资源返回的页面,可以不配置,或者指向4042.用量封顶配置(重要)如果网站不是非常重要,又怕被攻击导致高额账单,这个是保底。可以设定一段时间内最大用量,同时到达时进行提前预警。3.SEO配置默认开启即可4.HTTP响应头配置通常不需要配置。使得每个通过cdn的都会返回给客户端的http响应头的内容5.智能压缩开启即可。6.离线缓存配置开启即可。开启后如果源站故障,这个也能显示,不过这个实际作用不是很大,除非是内容型网站,很少和后端交互。7.POST请求大小配置默认为1M(nginx的默认也是1M)建议不要动,请求通常不会超过1M,如果是post上传大文件,建议分段后上传。参考文章: cdn配置(超详细+图解+原理)
2024年04月20日
24 阅读
0 评论
0 点赞
1
2
...
22
✖
使用
Typecho
建站,并搭配
joe
主题(有修改)
蜀ICP备2022005623号
川公网安备 51012202001212号
本站已运行
00
天
00
时
00
分
00
秒
Copyright © 1970 ~
Xcshare
All rights reserved.