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

中英互译网站怎么做it运维需要具备哪些能力

中英互译网站怎么做,it运维需要具备哪些能力,做视频赚钱的网站有哪些,工程建设沈阳网Spring Boot与监控管理视频 1. 简介 通过引入spring-boot-starter-actuator, 可以使用SpringBoot为我们提供的准生产环境下的应用监控和管理功能。我们可以通过http, jmx, ssh协议来进行操作#xff0c;自动得到审计、健康及指标信息等。 步骤#xff1a; 引入spring-boo…Spring Boot与监控管理视频 1. 简介 通过引入spring-boot-starter-actuator, 可以使用SpringBoot为我们提供的准生产环境下的应用监控和管理功能。我们可以通过http, jmx, ssh协议来进行操作自动得到审计、健康及指标信息等。 步骤 引入spring-boot-starter-actuator通过http方式访问监控端点可进行shutdown post提交此端点默认关闭 监控和管理端点 端点名描述autoconfig所有自动配置信息auditevents审计事件beans所有Bean的信息configprops所有配置属性dump线程状态信息env当前环境信息health应用健康状况info当前应用信息metrics应用的各项指标mappings应用的RequestMapping映射路径shutdown关闭当前应用默认关闭trace追踪信息最新的http请求 http://localhost:8080/beans http://localhost:8080/health http://localhost:8080/trace http://localhost:8080/metrics http://localhost:8080/mappings http://localhost:8080/info 2. shutdown端点的使用 首先在application中开启shutdown端点默认是关闭的。 # 关闭认证 management.security.enabledfalse # 开启shutdown端点 endpoints.shutdown.enabledtrue启动应用后使用postman发送post请求 http://localhost:8080/shutdown; 发现报跨域访问限制异常。 {timestamp: 1691418900478,status: 403,error: Forbidden,message: Invalid CSRF Token null was found on the request parameter _csrf or header X-CSRF-TOKEN.,path: /shutdown }什么是 CSRF 这是一个 WEB 应用安全的问题CSRFCross-site request forgery 跨站请求伪造也被称为“One Click Attack” 或者Session Riding攻击方通过伪造用户请求访问受信任站点。 因为我在应用中引入了spring-security, 它引入了CSRF默认是开启。CSRF和RESTful技术有冲突。CSRF默认支持的方法 GET|HEAD|TRACE|OPTIONS不支持POST。 其实跨域攻击操作过程比较简单就是如果你不采取任何限制的时候对 POST 相对风险系数比较高的访问用户可以伪造请求然后对服务器进行攻击和修改。比如说通过伪造 POST 请求然后能够将用户的数据删除。 参考 Spring security CSRF 跨域访问限制问题 - 知乎 (zhihu.com) 我们只需要禁用CSRF就可以了。http.csrf().disable(); EnableWebSecurity public class MySecurityConfig extends WebSecurityConfigurerAdapter {/*** 定制请求的授权规则** param http the {link HttpSecurity} to modify* throws Exception*/Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().antMatchers(/).permitAll()// VIP1角色的用户才能访问level1的页面其他同理.antMatchers(/level1/**).hasRole(VIP1).antMatchers(/level2/**).hasRole(VIP2).antMatchers(/level3/**).hasRole(VIP3);// 开启自动配置的登录功能 // http.formLogin();http.formLogin().usernameParameter(uname).passwordParameter(pwd).loginPage(/userlogin).loginProcessingUrl(/userlogin);// 1. 如果没有访问权限转发到/login请求来到登录页// 2. 重定向到/login?error表示登录失败。 更多详细规定// 3. 默认post形式的/login代表处理登录提交// 4.如果定制loginPage那么loginPage的post请求就是登录提交// 开启自动配置的注销功能, 访问/logout表示用户注销清空session; 注销成功后来到首页;http.logout().logoutSuccessUrl(/);// 开启记住我的功能, 将cookie发给浏览器保存以后登录带上这个cookie只要通过服务器端的验证就可以免登录// 如果点击”注销“也会删除这个cookie // http.rememberMe();http.rememberMe().rememberMeParameter(remember);// 禁用csrfhttp.csrf().disable();}/*** 定制认证规则** param auth the {link AuthenticationManagerBuilder} to use* throws Exception*/Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {auth.inMemoryAuthentication().withUser(zhangsan).password(123456).roles(VIP1, VIP2).and().withUser(lisi).password(123456).roles(VIP2, VIP3).and().withUser(wangwu).password(123456).roles(VIP1, VIP3);} }再次访问应用被关闭。使用 curl -X POST http://localhost:8080/shutdown 也可以。 {message: Shutting down, bye... }3. 定制端点信息 定制端点一般通过endpoints 端点名 属性名来设置修改端点id endpoints.beans.idmybeans);开启远程应用关闭功能 endpoints.shutdown.enabledtrue关闭端点endpoints.beans.enabledfalse开启所需端点 endpoints.enabledfalse;endpoints.beans.enabledtrue; 定制端点访问路径 management.context-path/manage;关闭http端点 management.port-1; management.security.enabledfalse info.app.idspringboot-security info..app.version1.0 #endpoints.metrics.enabledfalse #endpoints.autoconfig.enabledfalse endpoints.shutdown.enabledtrue # http://localhost:8080/bean endpoints.beans.idmybean endpoints.beans.path/bean # http://localhost:8080/du endpoints.dump.path/du # 关闭所有端点访问 endpoints.enabledfalse # 开启指定端点访问 endpoints.beans.enabledtrue # 所有端点访问根路径 http://localhost:8080/manage/bean management.context-path/manage # 所有端点访问端口 http://localhost:8181/manage/bean management.port81814. 健康状态监控 开放health端点访问 endpoints.health.enabledtruehttp://localhost:8181/manage/health 响应 {status: UP,diskSpace: {status: UP,total: 362095308800,free: 336869535744,threshold: 10485760} }现在来模拟服务失败的场景比如引入redis依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactId /dependency然后配置reids主机地址 # redis spring.redis.host192.168.111.129因为我虚拟机上的redis服务没有启动应用是无法连接redis的。我们来查看health端点状态 http://localhost:8181/manage/health {status: DOWN,diskSpace: {status: UP,total: 362095308800,free: 336868065280,threshold: 10485760 }, redis: {status: DOWN,error: org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool} }启动远程redis服务后再次查看health端点, 其实是RedisHealthIndicator提供了监控支持。 {status: UP,diskSpace: {status: UP,total: 362095308800,free: 335793897472,threshold: 10485760 }, redis: {status: UP,version: 6.2.6} }5. 自定义健康状态指示器 编写一个指示器实现HealthIndicator接口 Component public class MyAppHealthIndicator implements HealthIndicator {Overridepublic Health health() { // Health.up().build() 成功// 自定义检查,直接返回失败return Health.down().withDetail(msg, 服务异常).build();} }启动应用后查看健康端点 http://localhost:8181/manage/health {status: DOWN,myApp: {status: DOWN,msg: 服务异常 }, diskSpace: {status: UP,total: 362095308800,free: 335793758208,threshold: 10485760 }, redis: {status: UP,version: 6.2.6} }
http://www.dnsts.com.cn/news/153729.html

相关文章:

  • 个人备案网站能用公司新网域名注册
  • 最火爆的国际贸易网站提供网站推广公司电话
  • 建设通招标网站上海专业建站最低价
  • 做平面设计都关注哪些网站企业网站优化策略
  • 一般做网站用什么字体比较合适手机版oa系统
  • 网站建设需要摊销多久百度推广官方
  • 网站整站优化深圳口碑最好的装修公司
  • 广州白云区网站开发建设景区网站的目的
  • 动漫网站建设目的搜索优化的培训免费咨询
  • 网站建设 官网python采集更新wordpress
  • 彩票网站上的走势图是怎么做的联想公司网站建设现状
  • 数商云电子商务网站建设正规劳动合同模板免费
  • 网站建设策划书编制crazyuncle WordPress
  • 网站建设工具的种类株洲市
  • 英文版网站制作wordpress改页面
  • 网页建设与网站设计ps 如何做网站
  • 郑州建设网站设计重庆微网站开发公司
  • 开发技术网站开发技术wordpress 淘宝客网站
  • 无锡自适应网站开发推广策划
  • 泸州北京网站建设宁波seo公司网站推广
  • 腾讯轻量应用服务器建站模板html 门户网站模板
  • 做外贸建网站需要推广吗网页紧急升级维护中升级
  • 做网站建设要学多久东莞品牌网站制作
  • iis网站数据库失败网址如何生成二维码
  • 做百度推广网站得多少钱如何修改wordpress首页导航
  • 服务器网站模板海安网站建设公司
  • 想学学做网站电子商务网站模板
  • 企业查询软件免费纺织品服装网站建设优化
  • 手机网站优化指南动态域名申请
  • 网站开发技术总监面试题网站怎么盈利