java - Kong反向代理后面的Spring Boot(具有安全性)无法正常工作

标签 java spring-boot spring-security-oauth2 kong

我有一个 Spring Boot 服务,其安全性高于 Keycloak。 该服务工作正常:http://localhost:8080/api/resource (受到限制)并且只有在通过 keycloak 进行身份验证后才能访问。

@Override
protected void configure(HttpSecurity http) throws Exception {
    super.configure(http);
    http.authorizeRequests().antMatchers("/open/*").permitAll()
    .anyRequest().authenticated();
}

现在我使用 Kong 作为外部世界的反向代理:其条目是(例如):https://gateway.example.com/customer重定向到 http://localhost:8080

调用 https://gateway.example.com/customer/api/resource 后,出了问题,改为调用https://gateway.example.com/customer/sso/login它调用 https://gateway.example.com/sso/login所以我得到“404 Not Found”。

安全部分似乎已删除或忽略该位置中的“客户”。

可以更正位置吗?

谢谢

最佳答案

如果您使用的是按路径匹配的路由,并且您不会删除该路由,则需要将 strip_path 设置为 true

检查documentation .

关于java - Kong反向代理后面的Spring Boot(具有安全性)无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47360382/

相关文章:

JsonFilter 抛出错误 "no FilterProvider configured for id"

java - 在 Spring Security 中实现大量级联角色和权限的更好方法?

JAVA : change font's size in java

java - Java BigDecimal.remainder() 的问题 - 不合理且不准确的返回

java - Collections.sort() 不适用于实现 Comparable 的类或使用 Comparator Java 时

spring-boot - Spring Boot devtools - 有时重新加载的 bean 在重新启动时不会被拾取

java - ORA-29481 : Implicit results cannot be returned to client when calling Oracle 12c procedure from JDBC

java - 没有API ID可以调用外部API吗?

java - Spring ,Oauth2 : authentication details lost after refreshing the token

java - 为什么 OAuth2 身份验证服务器使用 jdbc 数据源返回 401 错误?