mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-10 21:19:00 +08:00
✨ Introducing new features. #1934 所有服务都接入到 Spring Boot Admin 监控
✨ Introducing new features. #1934 所有服务都接入到 Spring Boot Admin 监控
This commit is contained in:
1 parent
163277fd16
commit
ecb238740c
5 files changed
+55
-11
No files matched your search
@@ -21,15 +21,30 @@ nacos:
|
||||
urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
datasource:
|
||||
platform: mysql
|
||||
security:
|
||||
enabled: true
|
||||
boot: # 接入 spring boot admin
|
||||
admin:
|
||||
client:
|
||||
url: http://pigx-monitor:5001
|
||||
username: pigx
|
||||
password: pigx
|
||||
|
||||
useAddressServer: true
|
||||
|
||||
# 关闭监控埋点采集
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
metrics:
|
||||
export:
|
||||
elastic:
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<!--注册中心客户端-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.csp</groupId>
|
||||
<artifactId>sentinel-core</artifactId>
|
||||
|
||||
+9
-7
@@ -20,16 +20,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -59,6 +54,8 @@ public class LoginAuthenticationFilter implements Filter {
|
||||
|
||||
private static final String URL_SUFFIX_DOT = ".";
|
||||
|
||||
private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher();
|
||||
|
||||
/**
|
||||
* Some urls which needn't auth, such as /auth/login, /registry/machine and so on.
|
||||
*/
|
||||
@@ -90,6 +87,10 @@ public class LoginAuthenticationFilter implements Filter {
|
||||
String servletPath = httpRequest.getServletPath();
|
||||
|
||||
// Exclude the urls which needn't auth
|
||||
if (authFilterExcludeUrls.stream().anyMatch(s -> PATH_MATCHER.match(s,servletPath))){
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
if (authFilterExcludeUrls.contains(servletPath)) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
@@ -106,6 +107,7 @@ public class LoginAuthenticationFilter implements Filter {
|
||||
authFilterExcludeUrlSuffix = URL_SUFFIX_DOT + authFilterExcludeUrlSuffix;
|
||||
}
|
||||
|
||||
|
||||
if (servletPath.endsWith(authFilterExcludeUrlSuffix)) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
server:
|
||||
port: 5020
|
||||
|
||||
spring:
|
||||
http:
|
||||
servlet:
|
||||
encoding:
|
||||
force: true
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
endpoint:
|
||||
health:
|
||||
show-details: ALWAYS
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
@@ -19,7 +26,7 @@ auth:
|
||||
username: sentinel
|
||||
password: sentinel
|
||||
filter:
|
||||
exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/version
|
||||
exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/version,/actuator/**,/details
|
||||
exclude-url-suffixes: htm,html,js,css,map,ico,ttf,woff,png
|
||||
|
||||
sentinel:
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
server:
|
||||
port: 5020
|
||||
servlet:
|
||||
encoding:
|
||||
force: true
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: ${NACOS_HOST:pigx-register}:${NACOS_PORT:8848}
|
||||
profiles:
|
||||
active: @profiles.active@
|
||||
Reference in new issue
Block a user