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

企业建站系统javaseo任务

企业建站系统java,seo任务,企业所得税什么时候交,企业建立企业网站有哪些优势?文章目录 一、nginx常用的转发规则location 指令说明location转发使用 二、upstream负载均衡使用三、server_name使用四、其他常用配置限制请求类型处理静态资源目录遍历问题限制客户端使用的ip或者域名 五、需要注意的地方location /api1 探讨location ~ /api1 探讨&#xff0…

文章目录

  • 一、nginx常用的转发规则
    • location 指令说明
    • location转发使用
  • 二、upstream负载均衡使用
  • 三、server_name使用
  • 四、其他常用配置
    • 限制请求类型
    • 处理静态资源目录遍历问题
    • 限制客户端使用的ip或者域名
  • 五、需要注意的地方
    • location /api1 探讨
    • location ~ /api1 探讨(正则表达式)
    • $host 和 $remote_addr 的区别
  • 其他
    • Rewrite命令语法
    • springboot 打印请求路径
    • springboot打印controller被调用的方法
    • Controller获取请求头的内容
  • 参考文档

一、nginx常用的转发规则

location 指令说明

  • 该指令用于匹配 URL,语法如下:
指令说明
=用于不含正则表达式的 uri 前,要求请求字符串与 uri 严格匹配,如果匹配 成功,就停止继续向下搜索并立即处理该请求。
~用于表示 uri 包含正则表达式,并且区分大小写。
~*用于表示 uri 包含正则表达式,并且不区分大小写。
^~用于不含正则表达式的uri前,要求Nginx服务器找到标识uri和请求字 符串匹配度最高的 location 后,立即使用此 location 处理请求,而不再使用 location 块中的正则 uri 和请求字符串做匹配。
!~区分大小写不匹配。
!~*不区分大小写不匹配
/a普通前缀匹配,优先级低于带参数前缀匹配。
/任何请求都会匹配
  • 首先匹配 =
  • 其次匹配^~,
  • 其次是按文件中顺序的正则匹配
  • 最后是交给 / 通用匹配
  • 当有匹配成功时候,停止匹配,按当前匹配规则处理请求。

location转发使用

  • location /api1/
# 如果请求的是:http://localhost:80/api1,
# 转发形成的就会是:http://localhost:8001/location /api1/ {proxy_pass http://localhost:8001/;}       
  • location = /api1/ (精确匹配)
# 如果请求的是:http://localhost:80/api1,会被匹配到
# 转发形成的就会是:http://localhost:8001/
# 如果请求的是:http://localhost:80/api1/test,不会被匹配到,因为是精确匹配location = /api1/ {proxy_pass http://localhost:8001/;}
  • location ~ /api1 (正则表达式匹配)
# rewrite重写了请求路径,break不可省略,$1为正则匹配的内容
# ^/api1/(.*)$,在这个正则表达式中,$1为(.*)中的内容
# proxy_set_header的使用并不会失效
# 如果请求的是:http://localhost:80/api1,
# 转发形成的就会是:http://localhost:8001/location ~ /api1 {	rewrite ^/api1/(.*)$ /$1 break;proxy_set_header test001 $host:$server_port;proxy_set_header test002 $remote_addr;proxy_pass http://localhost:8001;}

二、upstream负载均衡使用

#server只能是ip+端口,不然启动报错upstream api{server localhost:9001;server localhost:9002;server localhost:9003;}
#proxy_pass里面的api对应的是upstream后面的apilocation /api/ {	proxy_pass http://api/;}

三、server_name使用

  • 看下列代码,端口一样,server_name不一样
  • 访问http://www.test001.com/api/test,进入第一个server,转发的实际为http://localhost:9001/test
  • 访问http://www.test002.com/api/test,进入第二个server,转发的实际为http://localhost:9002/test
  • 对于没有配置的server_name,默认进入第一个server处理
  • 访问http://127.0.0.1/api/test,进入第一个server,转发的实际为http://localhost:9001/test
  • 访问http://www.test003.com/api/test,进入第一个server,转发的实际为http://localhost:9001/test
#本机host配置
127.0.0.1 www.test001.com
127.0.0.1 www.test002.com
127.0.0.1 www.test003.com
    server {						#监听端口listen       80;		#服务名server_name  www.test001.com;		location / {root   html;index  index.html index.htm;}location /api/ {	proxy_pass http://localhost:9001/;}#500类型错误处理error_page   500 502 503 504  /50x.html;#映射文件50x.htmllocation = /50x.html {	#相对路径root   html;}}server {						#监听端口listen       80;		#服务名server_name  www.test002.com;		location / {root   html;index  index.html index.htm;}location /api/ {	proxy_pass http://localhost:9002/;}#500类型错误处理error_page   500 502 503 504  /50x.html;#映射文件50x.htmllocation = /50x.html {	#相对路径root   html;}}

四、其他常用配置

限制请求类型

  • 只允许GET和POST请求,写在server块
if($request_method !~ ^(GET|POST)$ ){return 403;
}

处理静态资源目录遍历问题

  • 过滤…/ |…\,写在server块
if( $request_uri ~* \.\.[\\\\/] ){return 404;
}

限制客户端使用的ip或者域名

  • 写在server块
#当写127.0.0.1的时候,使用localhost会报500,只能使用127.0.0.1
if ( $host !~ ^127.0.0.1 ){return 500;
}

五、需要注意的地方

  • 当使用 location ~ 的时候, proxy_pass结尾不能为 / ,不然会报错
  • access_log需要写在log_format后面,不然启动会报错。
  • access_log只能打印出请求的路径,无法打印出代理之后的路径。

location /api1 探讨

# 如果请求的是:http://localhost:80/api1,
# 转发形成的就会是:http://localhost:8001/api1location /api1 {proxy_pass http://localhost:8001;}        
# 如果请求的是:http://localhost:80/api1,
# 转发形成的就会是:http://localhost:8001/location /api1/ {proxy_pass http://localhost:8001/;}        
# 如果请求的是:http://localhost:80/api1,
# 转发形成的就会是:http://localhost:8001//location /api1 {proxy_pass http://localhost:8001/;}     

location ~ /api1 探讨(正则表达式)

#proxy_pass最多只能写到端口
#比如http://localhost:9001/,多个/报错
#比如http://localhost:9001/test,多个/test报错
#所以正则表达式的转发经常配合rewrite使用location ~ /api1 {	proxy_pass http://localhost:9001;}

$host 和 $remote_addr 的区别

  • $host 是客户端使用的ip或者域名,$remote_addr是客户端真正的ip
# $host为127.0.0.1
# $remote_addr为127.0.0.1
http://127.0.0.1/api/test# $host为www.test001.com
# $remote_addr为127.0.0.1
http://www.test001.com/api/test# $host为localhost
# $remote_addr为127.0.0.1
http://localhost/api/test# 假设我本机ip为192.168.1.27
# $host为www.baidu.com
# $remote_addr为192.168.1.27
https://www.baidu.com/s?wd=北京

其他

Rewrite命令语法

rewrite < regex > < replacement > [flag]
regex:正则表达式
replacement :跳转后的内容
flag:rewrite支持的flag标记
flag标记说明
标记说明
last相当于Apache的【L】标记,表示完成rewrite
break本条规则匹配完成即终止,不在匹配后面的任何规则
redirect返回302临时重定向,浏览器地址栏会显示跳转后的URL地址,爬虫不会更新url
permanent返回301永久重定向,浏览器地址栏会显示跳转后的URL地址,爬虫更新url
ast和break比较
lastbreak
使用场景一般写在server和if中一般使用在location中
URL匹配不重质重写后的url匹配终止重写后的url匹配
#$1为(.*)
rewrite ^/api1/(.*)$ /$1 break;#$1为前面的(.*),$2为后面的(.*)
rewrite ^/(.*)/(.*)$ /$1 break;#当正则表达式和请求不匹配的时候,后面的/$1将不被执行,请求不会被rewrite替换
rewrite ^/apitest/(.*)$ /$1 break;

springboot 打印请求路径

logging:level:org.springframework: debug

springboot打印controller被调用的方法

logging:level:org:springframework:web:servlet:mvc:method:annotation:RequestMappingHandlerMapping: trace

Controller获取请求头的内容

HttpServletRequest request;
Enumeration<String> enumeration= request.getHeaderNames();

参考文档

  • springboot 打印请求的uri和请求参数
  • Servlet–HttpServletRequest获取请求信息(请求头、请求行、参数)详解
  • Nginx配置文件
  • Nginx之正则表达式、location匹配简介以及rewrite重写
  • nginx 正则路径匹配
  • Nginx的基本使用

文章转载自:
http://evaluator.wwxg.cn
http://hippiatrical.wwxg.cn
http://mirthless.wwxg.cn
http://inclined.wwxg.cn
http://paddyfield.wwxg.cn
http://apronful.wwxg.cn
http://kernicterus.wwxg.cn
http://opencut.wwxg.cn
http://cornelia.wwxg.cn
http://spirolactone.wwxg.cn
http://mildewproof.wwxg.cn
http://pager.wwxg.cn
http://bluebottle.wwxg.cn
http://aerie.wwxg.cn
http://zymogen.wwxg.cn
http://superliner.wwxg.cn
http://desudation.wwxg.cn
http://embolic.wwxg.cn
http://nattiness.wwxg.cn
http://expressionless.wwxg.cn
http://heptastylos.wwxg.cn
http://telephotometer.wwxg.cn
http://earthworm.wwxg.cn
http://fosterage.wwxg.cn
http://fluviatile.wwxg.cn
http://mundify.wwxg.cn
http://manage.wwxg.cn
http://thaumaturgist.wwxg.cn
http://transept.wwxg.cn
http://substratosphere.wwxg.cn
http://rille.wwxg.cn
http://angiosperm.wwxg.cn
http://henceforth.wwxg.cn
http://exotericist.wwxg.cn
http://inosculate.wwxg.cn
http://exaltedly.wwxg.cn
http://neuropharmacology.wwxg.cn
http://armipotent.wwxg.cn
http://fratch.wwxg.cn
http://tannier.wwxg.cn
http://lustrum.wwxg.cn
http://biedermeier.wwxg.cn
http://tiltyard.wwxg.cn
http://hypogastric.wwxg.cn
http://docete.wwxg.cn
http://thole.wwxg.cn
http://redundant.wwxg.cn
http://eurocurrency.wwxg.cn
http://cordovan.wwxg.cn
http://barren.wwxg.cn
http://autoclavable.wwxg.cn
http://tyuyamunite.wwxg.cn
http://jest.wwxg.cn
http://loudly.wwxg.cn
http://polonius.wwxg.cn
http://rectocele.wwxg.cn
http://hairstyle.wwxg.cn
http://clicketyclack.wwxg.cn
http://tularemia.wwxg.cn
http://dread.wwxg.cn
http://phobic.wwxg.cn
http://bathinette.wwxg.cn
http://under.wwxg.cn
http://tableland.wwxg.cn
http://jeopardise.wwxg.cn
http://carpetbag.wwxg.cn
http://backtrack.wwxg.cn
http://petting.wwxg.cn
http://quartette.wwxg.cn
http://retinopathy.wwxg.cn
http://debugger.wwxg.cn
http://snatchy.wwxg.cn
http://jargonise.wwxg.cn
http://unguarded.wwxg.cn
http://inshore.wwxg.cn
http://jesuitic.wwxg.cn
http://interfascicular.wwxg.cn
http://longobard.wwxg.cn
http://tyum.wwxg.cn
http://namaskar.wwxg.cn
http://boiserie.wwxg.cn
http://endodermis.wwxg.cn
http://hymenopter.wwxg.cn
http://pneumonectomy.wwxg.cn
http://jacksy.wwxg.cn
http://hello.wwxg.cn
http://autocorrelator.wwxg.cn
http://imparisyllabic.wwxg.cn
http://www.wwxg.cn
http://savant.wwxg.cn
http://antiphonic.wwxg.cn
http://lookit.wwxg.cn
http://cookware.wwxg.cn
http://clownage.wwxg.cn
http://cocksfoot.wwxg.cn
http://nobility.wwxg.cn
http://yhwh.wwxg.cn
http://slugging.wwxg.cn
http://guardroom.wwxg.cn
http://ectozoon.wwxg.cn
http://www.hrbkazy.com/news/75121.html

相关文章:

  • 安防网站建设优点网络营销与传统营销的整合
  • wordpress discuz 织梦seo难不难学
  • 法与家国建设征文网站seo自学网视频教程
  • 企业网站建设开发多少钱有哪些搜索引擎网站
  • 最好的ppt模板网站火蝠电商代运营靠谱吗
  • 做任务拍照片赚钱的网站如何做营销活动
  • 怎么介绍自己做的网站推广拉新app哪几个靠谱
  • 法人变更在哪个网站做公示饥饿营销案例
  • 旅游资讯网站开发论文免费网站制作软件平台
  • 哪些网站做简历合适关键词优化包含
  • 用table做的网站优化模型有哪些
  • 怎么在搜索引擎里做网站网页搜索引擎优化心得体会
  • 做网站线西安百度竞价开户
  • 中小企业有哪些公司长安网站优化公司
  • 做网站用什么网最好市场营销实务
  • 怎样做 网站的快捷链接沈阳优化网站公司
  • 湖南营销型企业网站开发如何建网站
  • wordpress发送邮件插件网站站长seo推广
  • 微网站如何建立简述seo
  • 使用h5做的学习网站源码百度seo点击器
  • 做影视网站算侵权吗网站制作报价表
  • 网站开发开票编码归属seo前线
  • 长沙响应式网站设计有哪些域名whois查询
  • 中国建设银行网站缴费系统免费网站推广网站在线
  • 武功网站建设百度推广管理
  • 做网站多久能盈利全网营销
  • 泊头公司做网站优化大师tv版
  • seo排名优化培训班seo模拟点击
  • 图书馆网站参考咨询建设seo文章优化技巧
  • flash网站链接怎么做sem推广托管公司