spring-boot - spring boot 重定向到本地 url
问题描述
我正在使用带有spring-security的spring-boot。
override fun configure(http: HttpSecurity) {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/login").permitAll()
.anyRequest().authenticated()
}
我遇到的问题是,当我使用: https://my-domain.com/testPath
而不是将我重定向到https://my-domain.com/login它重定向到 http://10.100.15.40:8541/ (这是它的内部 IP 和端口)
这里有一些日志:
2019-06-27 08:20:31.031 DEBUG 7 --- [nio-8541-exec-1] o.s.s.w.s.HttpSessionRequestCache : DefaultSavedRequest added to Session: DefaultSavedRequest[http://10.100.15.40:8541/testPath]
2019-06-27 08:20:31.040 DEBUG 7 --- [nio-8541-exec-1] o.s.s.web.DefaultRedirectStrategy : Redirecting to 'http://10.100.15.40:8541/login'
2019-06-27 08:23:50.634 DEBUG 7 --- [nio-8541-exec-2] o.s.s.w.s.DefaultSavedRequest : requestURL: arg1=http://10.100.15.40:8541/testPath; arg2=http://10.100.15.40:8541/testPath (property equals)
2019-06-27 08:23:50.634 DEBUG 7 --- [nio-8541-exec-2] o.s.s.w.s.DefaultSavedRequest : serverName: arg1=10.100.15.40; arg2=10.100.15.40 (property equals)
任何人都知道我在哪里可以将其配置为不使用内部 ip?
解决方案
我发现了问题所在。问题是spring应用程序在代理后面。并且代理服务器没有发送标头 X-Forwarded-For。为了解决这个问题,我需要正确配置代理服务器。
推荐阅读
- ios - 实时数据库未返回预期数据
- windows - 使用 wget 从 EarthData(GES 光盘)下载许多文件。出现错误 503:某些文件的服务暂时不可用
- selenium - 在 Zalenium Dashboard 中将测试标记为通过
- sql - 在报告中选择不带空值的查询
- apache-kafka - Kafka - 计算存储在 kafka 主题中一段时间或字符串的消息数量
- sas - 我可以在 case 子句中使用子查询吗
- design-patterns - 两个有界上下文之间的身份引用
- vue.js - 无法从对象数组中删除对象
- fortran - Fortran 子例程/函数参数名称和声明
- sql-server - 如何将 HRESULT 转换为 sql 中的可读错误