亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Spring登錄表單從https切換為http

Spring登錄表單從https切換為http

富國滬深 2023-10-13 15:23:52
我們有一個 Spring boot 應用程序,在服務器上部署了 Spring security。我們使用 https,但是當重定向到 Spring 默認登錄表單時,會使用 http 調用重定向,這會導致 503 服務不可用。我不明白為什么Spring要切換通信協議,有沒有辦法阻止它?我們的配置protected void configure(HttpSecurity http) throws Exception {    http        .authorizeRequests()            .antMatchers("/", "/home", "/status", "/actuator").permitAll()            .anyRequest().authenticated()            .and()        .formLogin()            .permitAll()            .and()        .logout()            .permitAll()            .and()        .csrf()            .disable();}要重定向的頁面:登錄 :
查看完整描述

2 回答

?
繁華開滿天機

TA貢獻1816條經驗 獲得超4個贊

這是一個代理問題,我只需在我的 application.properties 中添加以下行

server.tomcat.remote-ip-header=x-forwarded-for
server.tomcat.protocol-header=x-forwarded-proto


查看完整回答
反對 回復 2023-10-13
?
呼啦一陣風

TA貢獻1802條經驗 獲得超6個贊

嘗試顯式啟用HSTS:

protected void configure(HttpSecurity http) throws Exception {

? ? http

? ? ? ? .headers()

? ? ? ? ? ? .hsts()

? ? ? ? .authorizeRequests()

? ? ? ? ? ? .antMatchers("/", "/home", "/status", "/actuator").permitAll()

? ? ? ? ? ? .anyRequest().authenticated()

? ? ? ? ? ? .and()

? ? ? ? .formLogin()

? ? ? ? ? ? .permitAll()

? ? ? ? ? ? .and()

? ? ? ? .logout()

? ? ? ? ? ? .permitAll()

? ? ? ? ? ? .and()

? ? ? ? .csrf()

? ? ? ? ? ? .disable();

}


查看完整回答
反對 回復 2023-10-13
  • 2 回答
  • 0 關注
  • 143 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號