Kong反向代理后面的Spring启动(带安全性)无法正常工作

时间:2017-11-17 22:46:08

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

我有一个Spring Key服务,具有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作为外面wolrd的反向代理:该条目是(例如):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,这样我就得到了#34; 404 Not Found"。

似乎安全部分删除或让我们说忽略"客户"在该位置。

有可能纠正位置吗?

由于

2 个答案:

答案 0 :(得分:0)

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

检查documentation

答案 1 :(得分:0)

我知道这个问题很古老,但是刚刚发生过。在application.properties中,尝试使用此设置:

server.use-forward-headers=true

这将告诉Spring Boot转发相对于代理而不是您的应用程序的请求。