Dav*_*rko 5 spring-security spring-boot
我将 SpringSecurity 与 SpringBoot 结合使用,并尝试限制来自特定 IP 地址的访问。我使用的是标准http.authorizeRequests().antMatchers("/api/**").access("hasIpAddress('xxx.xxx.xxx.xxx/16')");,直接访问服务器时它可以正常工作。但生产系统却是haproxy。我们使用 haproxy 向我们的应用程序发送 X-Forwarded-For 信息,并添加这两行 info application.properties
server.use-forward-headers=true
server.tomcat.remote-ip-header=X-Forwarded-For
Run Code Online (Sandbox Code Playgroud)
...但仍然无法访问该网址。知道缺少什么或者是否必须采取不同的措施来检查转发的远程 IP?
小智 1
对我来说,我必须设置
server.tomcat.remoteip.remote-ip-header=X-Forwarded-For
Run Code Online (Sandbox Code Playgroud)
代替
server.tomcat.remote-ip-header=X-Forwarded-For
Run Code Online (Sandbox Code Playgroud)
财产
| 归档时间: |
|
| 查看次数: |
511 次 |
| 最近记录: |