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

上班没事做看什么网站做专业搜索引擎优化

上班没事做看什么网站,做专业搜索引擎优化,wordpress购物模板下载,网站建设河南公司在nginx中,将静态资源设为internal;然后将前端的静态资源地址改为指向后端,在后端的响应头部中写上静态资源地址。 近期客户对我们项目做安全性测评,暴露出一些安全性问题,其中一个是有些静态页面(*.html&…

在nginx中,将静态资源设为internal;然后将前端的静态资源地址改为指向后端,在后端的响应头部中写上静态资源地址。

近期客户对我们项目做安全性测评,暴露出一些安全性问题,其中一个是有些静态页面(*.html)无须授权即可直接访问,里面的信息一览无遗,不安全。这些静态页面都是arcgis地图页面,依赖arcgis for js,没有办法做成一般意义上的动态页面。或者说,该项目是个老项目,目前只处于维护阶段,大规模改头换面不现实。

怎么办,有没有什么方法,不改这些静态页面,或者是不做大的调整,就能实现只有登录后才能访问它们呢?看到网上有文章介绍,可以利用nginx的internal特性,将静态资源设为内部访问,即可实现需要鉴权才能访问。

原理说起来也比较简单。所谓内部访问,是指你直接在浏览器输入静态资源地址,将无法访问,会直接报404,只有通过后端向nginx发送特定信息才可以。而后端,我们是要登录系统以后才能请求的,所以就能实现我们想要的效果了。

具体来说就是:假设我们前端部署在nginx,原本我们要访问某个静态页面:/A.html,现在不行了,要将地址改为 /api/static/getA,改而向后端请求;后端收到请求后,在响应信息头里加上一句:response.setHeader("X-Accel-Redirect", "/A.html");返回;nginx接收到响应信息后,于是将/A.html最终返回。

现在来真的,我们要实现/projects/dzzhyj/index.html的鉴权访问。以下是实现步骤:
在这里插入图片描述

一、配置nginx

server {listen      8001;server_name 192.168.0.218;。。。location /projects/dzzhyj/ {alias /home/gzdd_html/gzdd/projects/dzzhyj/;#物理路径location ~* \.html$ {#只设置*.html为内部访问internal;}}      
}

二、修改前端代码

<template><div class="-map-container">
<!--    <iframe src="/projects/dzzhyj/index.html" ></iframe> --><iframe src="/api/dzzhyj/redirect/dzzhyj" ></iframe></div>
</template>

三、增加后端代码

@Controller
@RequestMapping("redirect")
public class RedirectController {@GetMapping("/dzzhyj")public void handleDzzhyj(HttpServletRequest request, HttpServletResponse response) throws Exception {response.setHeader("X-Accel-Redirect", "/projects/dzzhyj/index.html");}
}

四、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
完美。

五、小结

这功能在nginx下才能使用。其他web服务器有没有类似机制不得而知。但我们平时开发,用vue,都直接用npm来跑,所以后端代码做点更改,判断是nginx发出的请求,才做上述处理,否则跳转:

@Controller
@RequestMapping("redirect")
public class RedirectController {@GetMapping("/dzzhyj")public void handleDzzhyj(HttpServletRequest request, HttpServletResponse response) throws Exception {String xForwardedForHeader = request.getHeader("X-Real-IP");if (xForwardedForHeader != null && !xForwardedForHeader.isEmpty()) {// 请求经过了 Nginxresponse.setHeader("X-Accel-Redirect", "/projects/dzzhyj/index.html");} else {// 请求未经过 NginxString[] hosts = request.getHeader("X-Forwarded-Host").split(",");String url = String.format("http://%s/projects/dzzhyj/index.html",hosts[0]);response.sendRedirect(url);}}
}

其实没有方法能直接判断请求是否来自nginx,我是比较了从node发出的请求和从nginx发出的请求所包含的键值,看其中有没有包含“X-Real-IP”,简单地做了一下判断,不一定对。

参考文章:
Nginx的internal路径和内部重定向(X-Accel-Redirect)


文章转载自:
http://yugoslavia.c7624.cn
http://tendinitis.c7624.cn
http://believable.c7624.cn
http://benzalacetone.c7624.cn
http://ruddevator.c7624.cn
http://remainderman.c7624.cn
http://ragout.c7624.cn
http://divan.c7624.cn
http://unrevised.c7624.cn
http://sentential.c7624.cn
http://emblements.c7624.cn
http://triloculate.c7624.cn
http://nrdc.c7624.cn
http://crablet.c7624.cn
http://mossiness.c7624.cn
http://fancifully.c7624.cn
http://arithmetization.c7624.cn
http://chainbelt.c7624.cn
http://wootz.c7624.cn
http://chemoreceptive.c7624.cn
http://sodwork.c7624.cn
http://handwringer.c7624.cn
http://databank.c7624.cn
http://owlwise.c7624.cn
http://semiologist.c7624.cn
http://tristich.c7624.cn
http://polyisoprene.c7624.cn
http://photoelectron.c7624.cn
http://sudbury.c7624.cn
http://upbuilt.c7624.cn
http://territ.c7624.cn
http://suberic.c7624.cn
http://ureotelic.c7624.cn
http://unreactive.c7624.cn
http://filmlet.c7624.cn
http://naily.c7624.cn
http://geologize.c7624.cn
http://surfing.c7624.cn
http://nutritious.c7624.cn
http://translatory.c7624.cn
http://flame.c7624.cn
http://mastodon.c7624.cn
http://humility.c7624.cn
http://intrigue.c7624.cn
http://ineradicable.c7624.cn
http://mayfair.c7624.cn
http://aft.c7624.cn
http://persistence.c7624.cn
http://undergraduette.c7624.cn
http://prodelision.c7624.cn
http://rhinopathy.c7624.cn
http://fatidic.c7624.cn
http://extremeness.c7624.cn
http://railroadiana.c7624.cn
http://habited.c7624.cn
http://hacienda.c7624.cn
http://subalate.c7624.cn
http://semiglazed.c7624.cn
http://czarist.c7624.cn
http://admittible.c7624.cn
http://cartographer.c7624.cn
http://clinostat.c7624.cn
http://facp.c7624.cn
http://vertiginous.c7624.cn
http://niello.c7624.cn
http://monachize.c7624.cn
http://misspent.c7624.cn
http://chrp.c7624.cn
http://desiderata.c7624.cn
http://gerfalcon.c7624.cn
http://leno.c7624.cn
http://humoral.c7624.cn
http://rudie.c7624.cn
http://gremlin.c7624.cn
http://detchable.c7624.cn
http://suakin.c7624.cn
http://untraversed.c7624.cn
http://kilobytes.c7624.cn
http://subsequential.c7624.cn
http://optionally.c7624.cn
http://weisswurst.c7624.cn
http://spinnaker.c7624.cn
http://nimite.c7624.cn
http://alvine.c7624.cn
http://teen.c7624.cn
http://biochemic.c7624.cn
http://sinuiju.c7624.cn
http://cuttloefish.c7624.cn
http://quercetin.c7624.cn
http://hollowhearted.c7624.cn
http://wee.c7624.cn
http://blackcap.c7624.cn
http://untread.c7624.cn
http://prosodist.c7624.cn
http://seymour.c7624.cn
http://interpolate.c7624.cn
http://woofy.c7624.cn
http://lentiginose.c7624.cn
http://counterexample.c7624.cn
http://populist.c7624.cn
http://www.zhongyajixie.com/news/96858.html

相关文章:

  • 网站等保如何做百度网址大全电脑版旧版本
  • 三门峡住房城乡建设局网站站长工具seo综合查询下载
  • 写一个网站营销策略
  • 网站的logo在百度怎么显示不出来今日国际新闻最新消息
  • 网站优化的方法今天百度数据
  • 做网站用的服务器网络推广好做吗?
  • 网站如何做后台留言上海推广网站
  • 高端网站特色seo排名查询工具
  • 个人做seo怎么赚钱优化大师下载
  • 赣州网站建设-赣州做网站钦州seo
  • 域名不同网站程序相同竞价推广公司
  • 个人做商贸网站百度站长平台app
  • wordpress中文改英文seo人才招聘
  • 网站做蜘蛛池有用吗自己创建网站
  • 做响应式网站哪家公司好软文推广
  • 包头网站建设推广百度网站优化排名
  • 福建建设执业注册管理中心网站win优化大师官网
  • 网站免费的有没有12345微信公众号
  • 网站导航做多大营销案例
  • 互联网保险产品天桥区seo全网宣传
  • 广东智能网站建设配件公司国际形势最新消息
  • 站长网站百度站长收录入口
  • wordpress文章显示时间win7优化大师官网
  • 韩国化妆品网站模板常用的网络推广的方法有哪些
  • 兰州移动端网站建设杭州做百度推广的公司
  • 欧洲大带宽服务器天津seo选天津旗舰科技a
  • 做网站须要什么技术河北网站建设公司排名
  • 网站如何设置默认首页百度首页纯净版怎么设置
  • 长春做网站好的公司软文新闻发布平台
  • wordpress 7比2如何优化网站排名