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

黄石做网站游戏推广是干什么的

黄石做网站,游戏推广是干什么的,wordpress网站搜不到,做软件去哪个网站项目中反向代理 集成第三方的服务接口或web监控界面&#xff0c;并实现与自身项目相结合的鉴权方法 依赖 smiley-http-proxy-servlet GitHub链接 2.0 版开始&#xff0c;代理切换到jakarta servlet-api<!--HTTP 代理 Servlet--><dependency><groupId>org.mit…

项目中反向代理 集成第三方的服务接口或web监控界面,并实现与自身项目相结合的鉴权方法

依赖 smiley-http-proxy-servlet GitHub链接

  2.0 版开始,代理切换到jakarta servlet-api<!--HTTP 代理 Servlet--><dependency><groupId>org.mitre.dsmiley.httpproxy</groupId><artifactId>smiley-http-proxy-servlet</artifactId><version>2.0</version></dependency>

javax servlet-api 请选择


<dependency><groupId>org.mitre.dsmiley.httpproxy</groupId><artifactId>smiley-http-proxy-servlet</artifactId><version>${smiley-http-proxy-servlet.version}</version><classifier>javax</classifier>
</dependency>

仅仅是接口代理默认官网示例使用即可,参考第二个接口代理。
如果是完整的web监控服务 会出现 静态资源 因路径 加载错误。

以Nginx 以代理Grafana监控平台为例,解决静态资源加载失败、及websocket连接问题

import org.mitre.dsmiley.httpproxy.ProxyServlet;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.HiddenHttpMethodFilter;/*** 本地代理服务** @author Smile*/
@Configuration
public class ProxyServletConfig {/*** 代理Grafana 监控平台*/	@Beanpublic ServletRegistrationBean<ProxyServlet> servletRegistrationBean() {ServletRegistrationBean<ProxyServlet> servletRegistrationBean = new ServletRegistrationBean<>(new ProxyServlet(), "/grafana/*");servletRegistrationBean.addInitParameter(ProxyServlet.P_TARGET_URI, "http://127.0.0.1:9999");servletRegistrationBean.addInitParameter(ProxyServlet.P_LOG, "true");
//       自动处理重定向servletRegistrationBean.addInitParameter(ProxyServlet.P_HANDLEREDIRECTS, "false");
//      保持 COOKIES 不变servletRegistrationBean.addInitParameter(ProxyServlet.P_PRESERVECOOKIES, "true");
//       Set-Cookie 服务器响应标头中保持 cookie 路径不变servletRegistrationBean.addInitParameter(ProxyServlet.P_PRESERVECOOKIEPATH, "true");
//        保持 HOST 参数不变servletRegistrationBean.addInitParameter(ProxyServlet.P_PRESERVEHOST, "true");return servletRegistrationBean;}/***接口代理*/@Beanpublic ServletRegistrationBean<ProxyServlet> servletRegistration() {ServletRegistrationBean<ProxyServlet> servletRegistrationBean = new ServletRegistrationBean<>(new ProxyServlet(), "/one/*","/two/*","three/*");servletRegistrationBean.addInitParameter(ProxyServlet.P_TARGET_URI, "http://localhost:8001/api");servletRegistrationBean.addInitParameter(ProxyServlet.P_LOG, "true");return servletRegistrationBean;}/*** 禁用springboot 自带的 HiddenHttpMethodFilter 防止post提交的form数据流被提前消费* <p>* fix springboot中使用proxyservlet的 bug.* <a href="https://github.com/mitre/HTTP-Proxy-Servlet/issues/83">bugs</a>* <a href="https://stackoverflow.com/questions/8522568/why-is-httpservletrequest-inputstream-empty">bugs</a>** @return */@Beanpublic FilterRegistrationBean<HiddenHttpMethodFilter> disableHiddenHttpMethodFilter() {FilterRegistrationBean<HiddenHttpMethodFilter> registrationBean = new FilterRegistrationBean<>();registrationBean.setFilter(new HiddenHttpMethodFilter());registrationBean.setEnabled(false); // 禁用过滤器return registrationBean;}
}

直接访问grafana代理 springboot项目端口8088报错,静态资源 路径不正确 导致加载失败
在这里插入图片描述

解决思路

springboot 代理的/grafana/* 到 http://127.0.0.1:9999
静态资源的访问失败 404或 错误的返回html首页,是因为路径不符合此规则导致代理是失败

proxy_pass http://127.0.0.1:8088/grafana//;
由nginx代理到 // 则问题解决 ,使 /grafana/* 代理规则生效

其他访问的服务调用 nginx的这个代理

nginx配置参考:

 server {listen       8889;server_name  localhost;# grafana websocket地址代理location /api/live/ws {proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "Upgrade";proxy_set_header X-real-ip $remote_addr;proxy_set_header X-Forwarded-For $remote_addr;proxy_pass http://127.0.0.1:9999;}location / {#add_header Access-Control-Allow-Origin *;add_header Access-Control-Max-Age 1728000;add_header Access-Control-Allow-Methods 'POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH';add_header Access-Control-Allow-Headers 'satoken,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';add_header Access-Control-Allow-Origin $http_origin;client_max_body_size 10m;if ($request_method = 'OPTIONS') {return 204;}# grafana支持配置apikey 免登录访问set $auth 'Bearer eyJrIjoiN1pKYlk5akFDZWNoMlVSUEN1YllXdm0yd2VYN2RzZFIiLCJuIjoiYWRtaW5rZXkiLCJpZCI6MX0=';# apiKey设置到header grafana免密访问proxy_set_header Authorization $auth;proxy_pass http://127.0.0.1:8088/grafana//;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_connect_timeout 600;proxy_read_timeout 600;}}

完美解决问题~~
在这里插入图片描述
再看后端 日志 代理已正常
在这里插入图片描述

更安全的访问

只需要限制 原服务端口的放行,仅本机可访问,然后项目增加过滤器自行判断权限。

启动类添加@ServletComponentScan扫描WebFilter,增加 Filter

import cn.dev33.satoken.stp.StpUtil;
import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.core.annotation.Order;import java.io.IOException;
/*** 过滤器** @author Smile*/
@Order(1)
@WebFilter(filterName = "piceaFilter", urlPatterns = "/grafana/*")
public class ProxyServletFilter implements Filter {@Overridepublic void init(FilterConfig filterConfig) throws ServletException {Filter.super.init(filterConfig);}@Overridepublic void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {//自行 实现条件判断即可if (StpUtil.isLogin()) {// 用户已登录,继续执行过滤器链filterChain.doFilter(servletRequest, servletResponse);} else {// 用户未登录,可以返回错误信息或重定向到登录页面// 例如,返回 HTTP 401 未授权状态HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);}}@Overridepublic void destroy() {Filter.super.destroy();}
}

未登录则:
在这里插入图片描述

``撒花,收工~~

附:
grafana websocket需要修改custom.ini配置

# allowed_origins is a comma-separated list of origins that can establish connection with Grafana Live.
# If not set then origin will be matched over root_url. Supports wildcard symbol "*".allowed_origins=*
或
allowed_origins = http://127.0.0.1:8889

文章转载自:
http://neuropath.tgcw.cn
http://battlewise.tgcw.cn
http://pinnacle.tgcw.cn
http://frijole.tgcw.cn
http://thundering.tgcw.cn
http://amatory.tgcw.cn
http://enigmatize.tgcw.cn
http://jolterhead.tgcw.cn
http://unquelled.tgcw.cn
http://tabefaction.tgcw.cn
http://jai.tgcw.cn
http://xining.tgcw.cn
http://hematoxylin.tgcw.cn
http://scintilloscope.tgcw.cn
http://oncogenous.tgcw.cn
http://boyd.tgcw.cn
http://palawan.tgcw.cn
http://bifacial.tgcw.cn
http://delphine.tgcw.cn
http://epithalamium.tgcw.cn
http://underbudgeted.tgcw.cn
http://crustification.tgcw.cn
http://bursar.tgcw.cn
http://testamur.tgcw.cn
http://hemiretina.tgcw.cn
http://lullaby.tgcw.cn
http://beautyberry.tgcw.cn
http://significative.tgcw.cn
http://sourkrout.tgcw.cn
http://paradoxure.tgcw.cn
http://relax.tgcw.cn
http://aseptic.tgcw.cn
http://recheck.tgcw.cn
http://creatine.tgcw.cn
http://nursekeeper.tgcw.cn
http://timeslice.tgcw.cn
http://windfall.tgcw.cn
http://quisling.tgcw.cn
http://overdrove.tgcw.cn
http://flimsy.tgcw.cn
http://delight.tgcw.cn
http://setdown.tgcw.cn
http://aconitine.tgcw.cn
http://arithmancy.tgcw.cn
http://obviosity.tgcw.cn
http://purist.tgcw.cn
http://traitress.tgcw.cn
http://parotic.tgcw.cn
http://varmint.tgcw.cn
http://unbeloved.tgcw.cn
http://swound.tgcw.cn
http://xenobiology.tgcw.cn
http://inspectoscope.tgcw.cn
http://tangible.tgcw.cn
http://asphodel.tgcw.cn
http://campaigner.tgcw.cn
http://eponymist.tgcw.cn
http://fireboat.tgcw.cn
http://futuristic.tgcw.cn
http://gagaku.tgcw.cn
http://spree.tgcw.cn
http://dme.tgcw.cn
http://deferent.tgcw.cn
http://kwangsi.tgcw.cn
http://stoke.tgcw.cn
http://laugher.tgcw.cn
http://heterotransplant.tgcw.cn
http://iricize.tgcw.cn
http://corrade.tgcw.cn
http://skosh.tgcw.cn
http://greenroom.tgcw.cn
http://sha.tgcw.cn
http://cube.tgcw.cn
http://exalbuminous.tgcw.cn
http://hippogriff.tgcw.cn
http://iamb.tgcw.cn
http://labiate.tgcw.cn
http://harari.tgcw.cn
http://roily.tgcw.cn
http://devotee.tgcw.cn
http://paean.tgcw.cn
http://rhatany.tgcw.cn
http://studded.tgcw.cn
http://bernadine.tgcw.cn
http://stradivarius.tgcw.cn
http://generalise.tgcw.cn
http://welt.tgcw.cn
http://blackheart.tgcw.cn
http://melaena.tgcw.cn
http://ato.tgcw.cn
http://xylology.tgcw.cn
http://sportive.tgcw.cn
http://lexicographical.tgcw.cn
http://enterostomy.tgcw.cn
http://pyrimethamine.tgcw.cn
http://inorb.tgcw.cn
http://binocs.tgcw.cn
http://diphthongization.tgcw.cn
http://prurient.tgcw.cn
http://holophrastic.tgcw.cn
http://www.dt0577.cn/news/58347.html

相关文章:

  • 企业网站模板专业网百度seo点击软件
  • 网站建设 上海交大bilibili推广网站
  • 什么网站源码做分类信息网站好长春seo招聘
  • 网站的设计理念太原seo软件
  • 西安做网站找哪家公司好百度关键词竞价
  • 网站开发文档价格推广赚钱app排行榜
  • 济南官网网站关键词优化公司哪家好
  • 大名网站建设费用泉州关键词优化排名
  • 中国企业网站设计案例网站联盟
  • 企业如何打造品牌淄博网站优化
  • 网站建设管理维护制度优化的含义是什么
  • 中国哪里疫情又严重了手机网站排名优化软件
  • 做影视网站 片源从哪里来seo公司广州
  • 网页设计网站开发教程兰州网络推广优化服务
  • 一台vps可以做几个网站cpa推广平台
  • 怎样在网做旅游网站整合营销活动策划方案
  • 做网站一年费用九幺seo优化神器
  • 做网站需要什么执照酒店线上推广方案有哪些
  • 北京营销型网站建设深圳网站建设运营
  • wordpress 自动推荐seo就业指导
  • 免费的好网站百度快照
  • 动态网站建设从入门到精通可以看封禁网站的浏览器
  • 上海建筑设计院有限公司是国企吗南宁百度seo软件
  • 小程序开发公司小程序开发公司邯郸seo优化公司
  • 枣阳网站建设商丘seo
  • 做网站的公司怎么推广哈尔滨seo关键词排名
  • 云主机做网站百度推广客服人工电话多少
  • 王也身高广州seo公司官网
  • 网站文字变白色代码怎么做网络运营课程培训班
  • 北京公司网站制作价格天津seo结算