中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

河南自助建站建設(shè)代理seo就是搜索引擎廣告

河南自助建站建設(shè)代理,seo就是搜索引擎廣告,網(wǎng)站如何做區(qū)域屏蔽代碼,青島企業(yè)做網(wǎng)站項目中反向代理 集成第三方的服務(wù)接口或web監(jiān)控界面&#xff0c;并實現(xiàn)與自身項目相結(jié)合的鑒權(quán)方法 依賴 smiley-http-proxy-servlet GitHub鏈接 2.0 版開始&#xff0c;代理切換到j(luò)akarta servlet-api<!--HTTP 代理 Servlet--><dependency><groupId>org.mit…

項目中反向代理 集成第三方的服務(wù)接口或web監(jiān)控界面,并實現(xiàn)與自身項目相結(jié)合的鑒權(quán)方法

依賴 smiley-http-proxy-servlet GitHub鏈接

  2.0 版開始,代理切換到j(luò)akarta 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>

僅僅是接口代理默認(rèn)官網(wǎng)示例使用即可,參考第二個接口代理。
如果是完整的web監(jiān)控服務(wù) 會出現(xiàn) 靜態(tài)資源 因路徑 加載錯誤。

以Nginx 以代理Grafana監(jiān)控平臺為例,解決靜態(tài)資源加載失敗、及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;/*** 本地代理服務(wù)** @author Smile*/
@Configuration
public class ProxyServletConfig {/*** 代理Grafana 監(jiān)控平臺*/	@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 服務(wù)器響應(yīng)標(biāo)頭中保持 cookie 路徑不變servletRegistrationBean.addInitParameter(ProxyServlet.P_PRESERVECOOKIEPATH, "true");
//        保持 HOST 參數(shù)不變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數(shù)據(jù)流被提前消費* <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報錯,靜態(tài)資源 路徑不正確 導(dǎo)致加載失敗
在這里插入圖片描述

解決思路

springboot 代理的/grafana/* 到 http://127.0.0.1:9999
靜態(tài)資源的訪問失敗 404或 錯誤的返回html首頁,是因為路徑不符合此規(guī)則導(dǎo)致代理是失敗

proxy_pass http://127.0.0.1:8088/grafana//;
由nginx代理到 // 則問題解決 ,使 /grafana/* 代理規(guī)則生效

其他訪問的服務(wù)調(diào)用 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設(shè)置到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;}}

完美解決問題~~
在這里插入圖片描述
再看后端 日志 代理已正常
在這里插入圖片描述

更安全的訪問

只需要限制 原服務(wù)端口的放行,僅本機(jī)可訪問,然后項目增加過濾器自行判斷權(quán)限。

啟動類添加@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 {//自行 實現(xiàn)條件判斷即可if (StpUtil.isLogin()) {// 用戶已登錄,繼續(xù)執(zhí)行過濾器鏈filterChain.doFilter(servletRequest, servletResponse);} else {// 用戶未登錄,可以返回錯誤信息或重定向到登錄頁面// 例如,返回 HTTP 401 未授權(quán)狀態(tài)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://www.risenshineclean.com/news/66168.html

相關(guān)文章:

  • 網(wǎng)站群建設(shè)工作百度廣告聯(lián)盟價格
  • 漳平網(wǎng)絡(luò)建站公司關(guān)鍵詞推廣是什么意思
  • 企業(yè)對企業(yè)的網(wǎng)站灰色詞優(yōu)化培訓(xùn)
  • 網(wǎng)站多語言建設(shè)國家免費培訓(xùn)網(wǎng)站
  • 如何做網(wǎng)站推廣西安百度推廣優(yōu)化公司
  • 那些網(wǎng)站做網(wǎng)批免費網(wǎng)絡(luò)空間搜索引擎
  • 目前熱門的網(wǎng)站建設(shè)語言seo+網(wǎng)站排名
  • 廣州企業(yè)如何建網(wǎng)站免費域名注冊二級域名
  • 網(wǎng)站建設(shè)優(yōu)化服務(wù)網(wǎng)絡(luò)營銷招聘崗位有哪些
  • 2345網(wǎng)址大全的網(wǎng)址廣州:推動優(yōu)化防控措施落
  • 做網(wǎng)站如何通過流量賺錢杭州seo網(wǎng)站優(yōu)化公司
  • 施工程找工程做哪個網(wǎng)站好營銷型網(wǎng)站建設(shè)怎么做
  • 尋找哈爾濱網(wǎng)站建設(shè)市場營銷試題庫(帶答案)
  • 做宣傳圖冊在什么網(wǎng)站浙江企業(yè)seo推廣
  • 自己做開獎網(wǎng)站seo外包方案
  • 阿里云做網(wǎng)站經(jīng)費seo優(yōu)化網(wǎng)頁
  • 武漢做網(wǎng)站制作創(chuàng)建網(wǎng)站免費注冊
  • 阿里云搭建自己的網(wǎng)站seo崗位是什么意思
  • smarty做網(wǎng)站百度圖片搜索引擎入口
  • 手機(jī)微網(wǎng)站建設(shè)方案網(wǎng)站怎么添加外鏈
  • 網(wǎng)站定向推送怎么做關(guān)鍵詞排名零芯互聯(lián)排名
  • 深圳個人外貿(mào)網(wǎng)站建排名優(yōu)化哪家好
  • 深圳建設(shè)局網(wǎng)站天津百度整站優(yōu)化服務(wù)
  • 網(wǎng)站右側(cè) 回到頂部站長工具流量統(tǒng)計
  • 仿站 做網(wǎng)站免費推廣網(wǎng)站排行榜
  • 好用的日本ip地址seo優(yōu)化要做什么
  • 溫州網(wǎng)站推廣站建設(shè)全媒體廣告策劃營銷
  • 網(wǎng)站建設(shè)發(fā)票內(nèi)容蘇州網(wǎng)站制作開發(fā)公司
  • 惠州高端網(wǎng)站建設(shè)寵物美容師寵物美容培訓(xùn)學(xué)校
  • 如何建設(shè)網(wǎng)站平臺企業(yè)seo優(yōu)化服務(wù)