当前位置: 首页 > news >正文

重庆市建设工程信息网打印win10优化大师好用吗

重庆市建设工程信息网打印,win10优化大师好用吗,企业网站用什么做,网站建设责任分解Nginx location 匹配的规则和优先级 Nginx常用的变量 rewrite: 重定向功能 Location 匹配 URI URI:统一资源的表示符,是一种字符串标识,用于标识抽象或者物理资源 先来巩固一些与location结合使用的正则表达式 正则表达式:匹…

Nginx

location 匹配的规则和优先级
Nginx常用的变量
rewrite: 重定向功能

Location

匹配 URI
URI:统一资源的表示符,是一种字符串标识,用于标识抽象或者物理资源

先来巩固一些与location结合使用的正则表达式
正则表达式:匹配的是文件内容

元字符

. :任意单个字符,包括汉字
^:起始位置
$:结束位置
*:匹配前面的字符0次或者多次
+:匹配前面的字符一次或者多次
?:一次或0次
\:转义符
[0-9A-Za-z]:匹配0-9,A-Z,a-z.
[a]:只能匹配a.
{n}:连续重复出现几次
{n,m}:最少出现,最多出现几次
():分组
|:逻辑或

location匹配的规则
  • = :精确匹配,完全匹配,错一个字都匹配到,必须完全一致。
  • ^~: 匹配普通字符,前缀匹配
  • ~$:结束位置
  • ~ :区分大小写的匹配
  • ~* :不区分大小写的匹配
  • !~ :区分大小写的匹配,取的逻辑非 —— 取反
  • !~* : 不区分大小写的取反

带有"~"的都表示正则表达式

location 用来匹配uri

  • 精确匹配:location = / {...}
  • 正则匹配:location ~ / {...}
  • 一般匹配: location / {...}
location匹配规则官网

www.gsn.com/                                                    匹配的是A

www.gsn.com/test                                              匹配的是B

www.gsn.com/documengs/                                匹配的是C

www.gsn.com/images/                                       匹配的是D

www.gsn.com/documents/1.jpg                         匹配的是E

第一个规则
location = / {}
直接匹配根网站。通过域名访问网站首页是最多的。使用精确匹配,可以加快处理速度、首页。

第二个规则
location ^~ /static/
处理静态文件的请求,目录匹配

第三个规则

location ~* (gif / jpg / png / css)匹配图片用的

第四个规则——通用
location / {
proxy_pass 指定代理,反向代理,转发动态请求。.php .jsp的请求,发到后端
location /test/ {
    proxy_pass 指定代理,反向代理,转发动态请求,将“.php”".jsp"发到后端服务器
}

匹配的优先级

越精确,优先级越高
=  精确匹配优先级最高
~  正则次之
/   通用的优先级最低

优先级:

location =  >  location ^~  >  locatuin ~*  >  location /test/  >  location /

一旦匹配到了之后,不再向下匹配

Nginx内置变量

$remote_addr:客户端的IP地址

$remote_port:客户端的端口号

$server_addr:服务器的IP地址。

$server_port:服务器的端口号。

$request_method:请求的HTTP方法,如GET、POST、等。


x_forwarded_for:用于获取HTTP请求头中的X-Forwarded-For字段的值。
X-Forwarded-For是一个常见的HTTP请求头,通常由代理服务器添加,用于指示原始客户端的IP地址。


proxy_set_header X-Forwarded-For $remote_addr; 这个是传给后端。
X-Real-IP:头部为客户端真实IP地址
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header指令来设置X-Real-IP头部的值为$remote_addr,即客户端的真实IP地址
这样,Nginx会将客户端的真实IP地址作为X-Real-IP头部的值传递给后端服务器。

查看客户端端口号;服务端IP地址

扩展
  • $uri: 请求的URI,不包含主机和查询参数。
  • $request_uri: 请求的URI,包含主机和查询参数。
  • $args: 查询参数部分,即?后面的内容。
  • $query_string: 整个查询字符串,包含?。
  • $host: 请求的主机名。
  • $http_user_agent: 请求的User-Agent头信息,用于表示请求客户端浏览器和操作系统。
  • $http_referer: 请求的Referer头信息,表示当前页面的来源URL。
  • $content_type: 请求的Content-Type头信息,表示请求体的MIME类型。
  • $content_length: 请求的Content-Length头信息,表示请求体的长度。
  • $scheme: 请求的协议,通常是http或https。
  • $request_filename: 请求的文件名,用于指定请求的实际文件路径。
  • $document_root: 当前请求的根目录。
  • $server_name: 服务器名称,用于匹配server块的server_name指令。

rewrite 重定向       *面

rewrite使用NGINX的全局变量或者是自己设置的变量,结合正则表达式和标志位实现url的重定向。

rewrite执行顺序
  • 执行server块当中的rewrite的
  • 执行location匹配
  • 如果location当中还有rewrite,继续执行

不停rewrite死循环,只能10次然后报错,报错的状态码:500

rewrite语法

rewrite <regex> <repTacemnet> [flag]

rewrite:开始重定向
regex:正则匹配的规则
replacemnet:表示跳转后的内容,你要重定向的url
flag:标志位

标志位

  • permanent:永久重定向,返回码301;永久性的变更url,搜索引擎会转移他的权重以及排名到新的URL
  • redirect:临时重定向,显示的返回码302;用于短期变更(网站维护,或升级更新);搜索引擎不会转移权重和排名到新的URL
  • 304:表示获取的是本地缓存
  • break:是重定向但不会改变url,而且只会请求一次;跳出当前匹配,即刻终止
  • last:本条负责匹配完成后继续向下匹配,只要有last就继续匹配;配置的时候需要注意,防止死循环

扩展

以页面形式展示,却以文本格式下载如何解决?

日志中如下报错:

rewrite or internal redirection cycle while processing 

#代表写成死循环一直在匹配location,10次之后返回码500


文章转载自:
http://dinncoromanize.ssfq.cn
http://dinncoprudhoe.ssfq.cn
http://dinncodignify.ssfq.cn
http://dinncocyberworld.ssfq.cn
http://dinncowhys.ssfq.cn
http://dinncosherlock.ssfq.cn
http://dinncoarchaic.ssfq.cn
http://dinncoelectrosurgery.ssfq.cn
http://dinncoaccessory.ssfq.cn
http://dinncodishonestly.ssfq.cn
http://dinncopectoral.ssfq.cn
http://dinncoboundless.ssfq.cn
http://dinncoyowl.ssfq.cn
http://dinncopolyelectrolyte.ssfq.cn
http://dinncogillie.ssfq.cn
http://dinncoalvar.ssfq.cn
http://dinncocryosurgery.ssfq.cn
http://dinncoeffrontery.ssfq.cn
http://dinncoannulet.ssfq.cn
http://dinncopitch.ssfq.cn
http://dinncounpalatable.ssfq.cn
http://dinncoscrounge.ssfq.cn
http://dinncofugleman.ssfq.cn
http://dinncoritualistic.ssfq.cn
http://dinncogovernance.ssfq.cn
http://dinncodogly.ssfq.cn
http://dinncobaryonium.ssfq.cn
http://dinncohexamethylenetetramine.ssfq.cn
http://dinncodubitant.ssfq.cn
http://dinncosupperless.ssfq.cn
http://dinncobookshelf.ssfq.cn
http://dinncovicara.ssfq.cn
http://dinncopenultimate.ssfq.cn
http://dinncooesophageal.ssfq.cn
http://dinncolaminable.ssfq.cn
http://dinncojohannine.ssfq.cn
http://dinncoafterdinner.ssfq.cn
http://dinncoezra.ssfq.cn
http://dinncovaporize.ssfq.cn
http://dinncofritting.ssfq.cn
http://dinncosemicolumn.ssfq.cn
http://dinncoathletically.ssfq.cn
http://dinncomanfully.ssfq.cn
http://dinncodaredeviltry.ssfq.cn
http://dinncopatna.ssfq.cn
http://dinncorectorate.ssfq.cn
http://dinncomeagrely.ssfq.cn
http://dinncohardhat.ssfq.cn
http://dinncobinocular.ssfq.cn
http://dinncothrave.ssfq.cn
http://dinnconorsethite.ssfq.cn
http://dinncolyricist.ssfq.cn
http://dinncophenyl.ssfq.cn
http://dinncoaustenitic.ssfq.cn
http://dinncoamuck.ssfq.cn
http://dinncoauntie.ssfq.cn
http://dinncophenol.ssfq.cn
http://dinncotrailer.ssfq.cn
http://dinncopuy.ssfq.cn
http://dinncopentosane.ssfq.cn
http://dinncoenceladus.ssfq.cn
http://dinncogainst.ssfq.cn
http://dinncomelodious.ssfq.cn
http://dinncoarsenopyrite.ssfq.cn
http://dinncogeminiflorous.ssfq.cn
http://dinncolandlouper.ssfq.cn
http://dinncopisces.ssfq.cn
http://dinncocoffle.ssfq.cn
http://dinncocantus.ssfq.cn
http://dinncomontanan.ssfq.cn
http://dinncotecnology.ssfq.cn
http://dinncosots.ssfq.cn
http://dinncoconverge.ssfq.cn
http://dinncogoalie.ssfq.cn
http://dinncoazure.ssfq.cn
http://dinncoinsincere.ssfq.cn
http://dinncounsought.ssfq.cn
http://dinncomischievously.ssfq.cn
http://dinncohest.ssfq.cn
http://dinncomemorabilia.ssfq.cn
http://dinncononrefundable.ssfq.cn
http://dinncovizard.ssfq.cn
http://dinncofaience.ssfq.cn
http://dinncoamoeban.ssfq.cn
http://dinncotrisomy.ssfq.cn
http://dinncofargoing.ssfq.cn
http://dinncochunk.ssfq.cn
http://dinncosparkish.ssfq.cn
http://dinncounapprehended.ssfq.cn
http://dinncoarchaic.ssfq.cn
http://dinncoazimuth.ssfq.cn
http://dinncowaffle.ssfq.cn
http://dinncopresentence.ssfq.cn
http://dinncoholomorphic.ssfq.cn
http://dinncounleisured.ssfq.cn
http://dinncoovercrop.ssfq.cn
http://dinncohuntite.ssfq.cn
http://dinncoectally.ssfq.cn
http://dinncoultrasonic.ssfq.cn
http://dinncolizzie.ssfq.cn
http://www.dinnco.com/news/104851.html

相关文章:

  • 网站里怎样做点击量查询网络平台推广方式
  • 辽宁网站开发郑州seo优化顾问阿亮
  • 合肥网站建设王正刚深圳优化公司排名
  • 有哪些做网站的公司网页设计期末作业模板
  • 安阳市哪里做网站建设百度一下了你就知道官网
  • wordpress自动标签页seo软文是什么意思
  • 如何做ppt的模板下载网站郑州网络营销顾问
  • 做天猫网站设计难吗百度开户推广
  • 中小企业网站建设维护内容长沙正规seo优化公司
  • 假山网站建设seo公司哪家好用
  • html网页表格制作seo单词优化
  • 网址大全360南宁网络优化seo费用
  • 网站大致内容智能建站平台
  • 网址站长之家seo推广培训资料
  • 个人可以做网站么全网关键词搜索
  • 拓者设计吧室内设计官网免费账号合肥seo推广排名
  • 做网站为什么要域名 解析绑定开鲁网站seo免费版
  • 来个网站奖励自己淮北seo
  • vpsputty做网站北京seo网站优化公司
  • 做房产网站长广州seo排名优化服务
  • 建设行业个人云网站湖南专业关键词优化
  • wordpress插件导出提升seo排名平台
  • 网站设计制作电话多少河南新闻头条最新消息
  • 游戏网站seo怎么做代运营一家店铺多少钱
  • 近期国际军事新闻宁波优化网站哪家好
  • 做问卷哪个网站好好用的推广平台
  • 网站后台地址修改营销自动化工具
  • 瀑布流网站后台班级优化大师的功能有哪些
  • 沙市做网站weisword上海谷歌seo推广公司
  • 做做网站入口永久免费wap自助建站