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

保定市共青团下属网站浙江企业网站建设

保定市共青团下属网站,浙江企业网站建设,网站运营建设方案,太谷网站建设服务器文章目录 1、使用Nginx增加认证。2、使用Spring Gateway增加认证 SkyWalking的可视化后台是没有用户认证功能的,默认下所有知道地址的用户都能访问,官网是建议通过网关增加认证。 本文介绍通过Nginx和Spring Gateway两种方式 1、使用Nginx增加认证。 生…

文章目录

    • 1、使用Nginx增加认证。
    • 2、使用Spring Gateway增加认证

SkyWalking的可视化后台是没有用户认证功能的,默认下所有知道地址的用户都能访问,官网是建议通过网关增加认证。
本文介绍通过Nginx和Spring Gateway两种方式

1、使用Nginx增加认证。

生成密钥

yum install -y httpd-tools
htpasswd -cb nginx/htpasswd skywalking rtgdbhyffddu#

配置nginx

worker_processes 1;
error_log stderr notice;
events {worker_connections 1024;
}
http {variables_hash_max_size 1024;access_log off;#ireal_ip_header X-Real-IP;charset utf-8;server {listen 8081;#auth_basic "Please enter the user name and password"; #这里是验证时的提示信息#auth_basic_user_file /data/skywalking/nginx/htpasswd;index  index.html;location / {root   html;index  index.html index.htm;#auth_basic on;auth_basic "Please enter the user name and password"; #这里是验证时的提示信息auth_basic_user_file /etc/nginx/htpasswd;proxy_pass http://172.17.0.9:8080;# WebSocket 穿透#proxy_set_header Origin "";#proxy_set_header Upgrade $http_upgrade;#proxy_set_header Connection "upgrade";}}
}

密码配置:/etc/nginx/htpasswd

skywalking:$apr1$FVaUB8RE$.brXLk5N.IsNRqm3.Vy2n1

在这里插入图片描述
在这里插入图片描述

2、使用Spring Gateway增加认证

主要是使用Spring Gateway和Spring Security的基础认证formLogin实现,
pom.xml使用的依赖包

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.penngo.web.gateway</groupId><artifactId>web_gateway</artifactId><version>1.0.0</version><properties><maven.compiler.source>17</maven.compiler.source><maven.compiler.target>17</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>2022.0.4</version><type>pom</type><scope>import</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>3.1.0</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>com.penngo.web.gateway.WebGatewayMain</mainClass><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins></build></project>

WebGatewayMain.java

package com.penngo.web.gateway;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class WebGatewayMain {public static void main(String[] args) {SpringApplication.run(WebGatewayMain.class, args);}
}

SecurityConfiguration.java配置

package com.penngo.web.gateway;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.web.server.SecurityWebFilterChain;import static org.springframework.security.config.Customizer.withDefaults;@EnableWebFluxSecurity
@Configuration
public class SecurityConfiguration {@BeanSecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) {http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated()).cors(cors->cors.disable()).csrf(csrf->csrf.disable()).formLogin(withDefaults());return http.build();}/*** 可以在代码中配置密码,也可以在application.xml中配置密码* @return*/
//    @Bean
//    MapReactiveUserDetailsService userDetailsService() {
//
//        UserDetails user = User.withDefaultPasswordEncoder()
//                .username("admin")
//                .password("123456")
//                .roles("USER")
//                .build();
//        return new MapReactiveUserDetailsService(user);
//    }
}

application.yml

server:port: 8081servlet:encoding:force: truecharset: UTF-8enabled: true
spring:application:name: gatewayappsecurity:user:name: admin2password: 123456

bootstrap.yml

spring:cloud:gateway:routes:- id: skywalkinguri: http://localhost:8080/# 绑定ip白名单predicates:- RemoteAddr=127.0.0.1/32,192.168.245.65/32

运行效果
在这里插入图片描述
在这里插入图片描述

http://www.tj-hxxt.cn/news/81827.html

相关文章:

  • 哪些公司做网站好以图搜图
  • 网站如何去分析今日热搜榜官网
  • 如何做的网站排第一手机百度如何发布作品
  • wordpress 时光捕手seo网站优化论文
  • 给网站平台做推广叫什么长沙seo男团
  • 江苏省建设厅网站公示服装品牌营销策划方案
  • 潍坊点睛做网站怎么样大数据网络营销
  • 哪做网站好百度官方免费下载安装
  • 自己做的网页怎么上传网站吗怎么推广app
  • wordpress 做的网站销售管理系统
  • 如何建设网站兴田德润怎么样龙岗百度快速排名
  • 深圳优秀网站设计体球网足球世界杯
  • 钉钉企业邮箱收费标准廊坊优化技巧
  • 小型网站设计及建设论文范本短期职业技能培训班
  • 寿光网站制作网络竞价推广开户
  • 我们的优势的网站最近的新闻大事10条
  • 怎么样让百度收录网站网络营销有哪些推广平台
  • 超值的镇江网站建设如何模板建站
  • 做百度竞价网站修改影响排名吗网推拉新app推广接单平台
  • 无锡营销型网站建设百度竞价广告代理
  • 基于jquery做的网站石家庄学院
  • 公益网站模板抖音网络营销案例分析
  • 政府门户网站建设 苏州免费搭建网站平台
  • 铜川微网站建设网络营销与直播电商专业学什么
  • 做网站建设网站制作宁波seo关键词费用
  • 深圳网站优化价格优化设计五年级下册语文答案
  • 中国建设监理协会网站继续教育系统百度推广
  • 做网站公司郑州郑州的网站建设公司排名有什么好用的搜索引擎
  • 私人兼职做网站开发web个人网站设计代码
  • 新出的app推广在哪找seo刷关键词排名软件