相关疑难解决方法(0)

heroku:spring boot仅使用https接入端点

我在heroku上部署了Spring Boot Java应用程序。我想确保只能通过https访问我的注册端点。到目前为止,我知道,heroku使用负载平衡器将每个https连接重定向到带有特殊标头(X-forwarded-porto)的http。我在用

compile("org.springframework.boot:spring-boot-starter-security")
Run Code Online (Sandbox Code Playgroud)

用于加密工具(哈希密码)。我已经将“ security.basic.enable”属性设置为false(实际上不知道在这种情况下是否重要。)。

已尝试设置以下设置:

tomcat:
  remote_ip_header: x-forwarded-for
  protocol_header: x-forwarded-proto
Run Code Online (Sandbox Code Playgroud)

在我的application.yml中

问题是,我如何才能强制仅通过https链接使用端点?对于http,它可能会返回404之类的内容。我正在使用gradle,它很难找到使用它的任何参考。尝试了一些在google中找到的东西,但是没有用(或者我不知道如何正确实现它们...)。我仍然可以使用邮递员通过http访问我的端点。现在看起来像这样:

@Controller
@RequestMapping("/users")
public class AccountController {
    @Autowired
    private AccountRepository accountDao;

    @RequestMapping(value = "/register", method = RequestMethod.POST, consumes = "application/json")
    public ResponseEntity<Resource<Account>> createAccount(@RequestBody @Valid Account account) { ... }
Run Code Online (Sandbox Code Playgroud)

java spring heroku

3
推荐指数
1
解决办法
938
查看次数

标签 统计

heroku ×1

java ×1

spring ×1