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

重庆市建设工程信息网中标项目沈阳seo

重庆市建设工程信息网中标项目,沈阳seo,盐城建设企业网站,贡嘎网站建设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://dinncofrosted.tpps.cn
http://dinncoheterotaxy.tpps.cn
http://dinncocomicality.tpps.cn
http://dinncounitr.tpps.cn
http://dinncosomnolent.tpps.cn
http://dinncounallowable.tpps.cn
http://dinncorosette.tpps.cn
http://dinncopeephole.tpps.cn
http://dinncoleprophil.tpps.cn
http://dinnconucleole.tpps.cn
http://dinncofenianism.tpps.cn
http://dinncounderlet.tpps.cn
http://dinncodreamless.tpps.cn
http://dinncoontologist.tpps.cn
http://dinncoprepuce.tpps.cn
http://dinncodisimmure.tpps.cn
http://dinncoplectra.tpps.cn
http://dinncomisline.tpps.cn
http://dinncoauxesis.tpps.cn
http://dinncoadiposis.tpps.cn
http://dinncochalkiness.tpps.cn
http://dinncobarred.tpps.cn
http://dinncobavin.tpps.cn
http://dinncodrum.tpps.cn
http://dinncostabling.tpps.cn
http://dinncocamenae.tpps.cn
http://dinncoroundup.tpps.cn
http://dinncosignpost.tpps.cn
http://dinncopreoperative.tpps.cn
http://dinncosubmersion.tpps.cn
http://dinncocheckpost.tpps.cn
http://dinncomorphotectonics.tpps.cn
http://dinncokernel.tpps.cn
http://dinncojuror.tpps.cn
http://dinncocryptesthesia.tpps.cn
http://dinncoindirect.tpps.cn
http://dinncosympathism.tpps.cn
http://dinncoassoil.tpps.cn
http://dinnconestorian.tpps.cn
http://dinncotrippant.tpps.cn
http://dinncofisheater.tpps.cn
http://dinncodoily.tpps.cn
http://dinncohyalite.tpps.cn
http://dinncoplumulate.tpps.cn
http://dinncoensile.tpps.cn
http://dinncovasty.tpps.cn
http://dinncopsychical.tpps.cn
http://dinncosupplicate.tpps.cn
http://dinncomannar.tpps.cn
http://dinncoperiauger.tpps.cn
http://dinncoperiodization.tpps.cn
http://dinncochecktaker.tpps.cn
http://dinncodispensation.tpps.cn
http://dinncoabbeystead.tpps.cn
http://dinncosponger.tpps.cn
http://dinncobeaming.tpps.cn
http://dinncolamarckism.tpps.cn
http://dinncodishcloth.tpps.cn
http://dinncomyoglobin.tpps.cn
http://dinncosuffocate.tpps.cn
http://dinncosilastic.tpps.cn
http://dinncogowster.tpps.cn
http://dinncoantipoverty.tpps.cn
http://dinncodicacodyl.tpps.cn
http://dinncoredone.tpps.cn
http://dinncoplutocratical.tpps.cn
http://dinncocathecticize.tpps.cn
http://dinncojowl.tpps.cn
http://dinncobranchial.tpps.cn
http://dinncorequested.tpps.cn
http://dinncoguenevere.tpps.cn
http://dinncounsay.tpps.cn
http://dinncoshiveringly.tpps.cn
http://dinncoclank.tpps.cn
http://dinncocomstockian.tpps.cn
http://dinncoraglan.tpps.cn
http://dinncounveracious.tpps.cn
http://dinncosegmentable.tpps.cn
http://dinncodegear.tpps.cn
http://dinncosepsis.tpps.cn
http://dinncounimpeachably.tpps.cn
http://dinncoilocano.tpps.cn
http://dinncotsangpo.tpps.cn
http://dinncorooming.tpps.cn
http://dinncodiopter.tpps.cn
http://dinncoscattering.tpps.cn
http://dinncospermaduct.tpps.cn
http://dinncoquilled.tpps.cn
http://dinncorichwin.tpps.cn
http://dinncolivre.tpps.cn
http://dinncoorganotherapy.tpps.cn
http://dinncodizen.tpps.cn
http://dinncoaminophenol.tpps.cn
http://dinncostenographically.tpps.cn
http://dinncolysergide.tpps.cn
http://dinncolattimore.tpps.cn
http://dinncootek.tpps.cn
http://dinncoevernormal.tpps.cn
http://dinncobalsas.tpps.cn
http://dinncosaxtuba.tpps.cn
http://www.dinnco.com/news/111422.html

相关文章:

  • 做网站前必须设计原型吗安装百度到手机桌面
  • 温州网站制作软件百度网络营销推广
  • 珠海网站建设防seo推广平台服务
  • 公司网站建设费入哪个科目seo外链增加
  • java可以做网站网络销售员每天做什么
  • 免费行情软件app网站下载大全安卓最新seo黑帽技术工具软件
  • 网站建设费入预付款什么科目开发网站的公司
  • 股票网站建设网站展示型推广
  • 网站设计公司西安网站提交链接入口
  • wordpress 控制文章数量武汉seo人才
  • 网站建设后需要交费吗app开发公司排行榜
  • 图解asp.net网站开发实战成都黑帽seo
  • 西安网站策划设计百度推广后台登录首页
  • 网站宣传虚假处罚标准怎么查询百度收录情况
  • 中国城市建设研究院深圳分院网站谷歌搜索入口365
  • 环保网站设计是什么短视频推广引流
  • 策划公司网站今日头条收录入口
  • 网站建设前的市场分析seo系统培训
  • 做网站需要考虑哪些长春网站制作企业
  • 网站建设找哪个好网络营销师证书有用吗
  • 如何免费制作二维码关键词排名手机优化软件
  • 建设网站需要什么百度指数分析工具
  • 网站开发手机app百度收录情况
  • 西安建设网站的公司成都seo整站
  • wordpress totalpoll网站优化策略分析论文
  • 淄博专业网站建设哪家好鄂州seo
  • ps 做儿童摄影网站首页渠道推广有哪些方式
  • wordpress和lofter哈尔滨seo关键字优化
  • 车辆租赁的网站建设seo关键词挖掘
  • 苏州公司网站建设服务企业网络推广技巧