Https Cloud foundy spring启动项目遇到重定向循环问题
全部,, 我创建了一个spring boot mvc项目,并希望将访问限制为https,因此我将其配置为如下Https Cloud foundy spring启动项目遇到重定向循环问题,https,spring-boot,cloud,cloud-foundry,Https,Spring Boot,Cloud,Cloud Foundry,全部,, 我创建了一个spring boot mvc项目,并希望将访问限制为https,因此我将其配置为如下 package com.example; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.Sprin
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableAutoConfiguration
@SpringBootApplication
public class Demo123Application {
public static void main(String[] args) {
SpringApplication.run(Demo123Application.class, args);
}
}
@Configuration
class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requiresChannel().anyRequest().requiresSecure();
}
}
但是当我在chrome上访问它时,就像。它在屏幕上显示重定向循环
我已经对application.yml进行了如下配置:
server:
port: 8443
tomcat:
remote_ip_header: x-forwarded-for
protocol_header: X-Forwarded-Proto
有人能帮忙吗?在我看来,你的代码和配置还不错。我有一个类似的项目,除了我使用的是一个属性文件而不是yml,并且没有提到端口。我更改了应用程序后缀并删除了端口,但仍然不起作用。希望您的应用程序正确读取yml。如有疑问,您可以尝试使用属性文件,就像我所做的那样。是的,我已经尝试了应用程序。属性仍然不起作用,:(那么不知道。如果这些链接有用: