使用AWS颁发的证书用于一个Spring Boot应用程序。

huangapple go评论74阅读模式
英文:

Use AWS issued certificate for a Spring Boot app

问题

我在AWS上运行了一个应用程序,其具有通过S3托管的React JS前端,并在EC2实例上托管有Spring Boot后端,位于负载平衡器后面。我已经为我的域获得了SSL证书,并且我使用CloudFront将HTTP请求重定向到HTTPS。

我的问题是,我可以通过HTTPS连接到负载平衡器,但是我的Spring Boot API不会从负载平衡器接受HTTPS。因此,我使用HTTP,每次我发送API调用到后端时,我的网站都会更改为“未安全”。

是否有一种方法可以在我的Spring Boot API中使用Amazon颁发的证书,以便它接受HTTPS调用?我只找到了使用自签名证书的教程,想知道是否可以使用我的AWS证书。

如果有方法,你能否请提供一些代码示例,我需要将其插入到我的application.properties文件中?

谢谢,
Kris

英文:

I have an app running on AWS that has got a React JS front-end hosted through S3 and Spring Boot back-end hosted on EC2 instances behind a load balancer. I got my SSL certificate for my domain and I use CloudFront to redirect HTTP requests into HTTPS.

My issue is that I can connect through HTTPS to my load balancer, however, my Spring Boot API won't accept HTTPS from the load balancer. Therefore I use HTTP and anytime I send an API call to my backend, my site changes to "Not Secured".

Is there a way to use the Amazon issued certificate in my Spring Boot API in order for it to accept HTTPS calls? I have only found tutorials using self-signed certs and was wondering if I can use my AWS certificate instead.

If there is a way, could you please provide an example of code I need to insert in my application.properties file?

Cheers
Kris

答案1

得分: 4

这部分问题实在是令人困惑,因为您没有提供关于您的意思的详细信息:

> 我的问题在于,我可以通过HTTPS连接到我的负载均衡器,但是我的Spring Boot API不会接受来自负载均衡器的HTTPS连接。

您的负载均衡器应该提供AWS ACM SSL证书。您应该编写您的应用程序,使您的网站对API进行SSL调用。负载均衡器应该通过在负载均衡器目标组设置中设置HTTP协议和端口,与您的Spring Boot后端服务器进行HTTP通信。

流量流程应如下所示:

Web浏览器 ->(HTTPS)API调用到负载均衡器 ->(HTTP)调用到后端Spring Boot服务器

英文:

This part of your question is really confusing, since you don't provide details about what you mean:

> My issue is that I can connect through HTTPS to my load balancer,
> however, my spring-boot API won't accept HTTPS from the load balancer.

Your load balancer should be serving the AWS ACM SSL certificate. You should code your application so that your website makes SSL calls to your API. The load balancer should communicate with your Spring Boot backend server over HTTP, by setting the HTTP protocol and port in the load balancer target group settings.

The traffic flow should look like this:

Web Browser -> (HTTPS) API call to Load Balancer -> (HTTP) call to backend Spring Boot server

huangapple
  • 本文由 发表于 2020年10月20日 21:25:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/64446146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定