java - Nginx 反向代理只允许经过身份验证的用户使用 Spring Boot api
问题描述
我的任务是用 Nginx 替换 Zuul 反向代理。Zuul 代理中的安全性是通过implementation 'org.springframework.boot:spring-boot-starter-security'
@EnableWebSecurity
class ZuulSecurity(...) : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
http.csrf().disable().httpBasic().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
.sessionFixation().changeSessionId()
.and().authorizeRequests()
.antMatchers(*dennyPatterns).denyAll()
.antMatchers(*loginPatterns).permitAll()
.anyRequest().authenticated()
.and().formLogin().loginPage(loginUrl)
}
}
Spring Boot api 服务的保护方式与@EnableWebSecurity
我将 Zuul 反向代理替换为 Nginx 作为反向代理。
如何在 Nginx 上强制执行安全性,以便没有未经身份验证proxy_pass
的请求被发送到后端 api 服务?- 换句话说,如果请求是由经过身份验证的用户发出的,我想在 Nginx 上进行验证(loginPatterns url 有一些例外)。我应该学习哪一个nginx/admin-guide/security-controls?
解决方案
我已经通过配置子请求身份验证/
推荐阅读
- python - 将数组转换为多项式
- reactjs - 使用 Emoiton Js 为 react 组件生成多个 css 类
- python - 通过 pip 安装 gTTS 工作正常,但将其导入程序会引发错误
- r - 如何将第二个数据集添加到 R 中的点图?
- python - 为什么这个函数会产生 (0,0,0,0,0)
- html-agility-pack - HtmlAgilitypack SelectSingleNode“System.NullReferenceException”
- node.js - 在 NodeJS 中的 async/await 内部循环
- java - 将dll文件加载到java类中
- python - fillna() 取决于列类型函数
- php - 在两个 laravel 中将 2 个集合合并到另一个具有相同值的集合中