在Hlastic beanstalk loadbalancer中将Http Url重定向到Https [英] Redirect Http Url to Https in Elastic beanstalk loadbalancer

查看:140
本文介绍了在Hlastic beanstalk loadbalancer中将Http Url重定向到Https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的启动应用程序运行在负载均衡器后面的tomcat EC2实例上,该实例已使用Https配置并使用Http进行内部协调。

I've my spring boot app running on tomcat EC2 instances behind the Loadbalancer, which has configured with Https and internelly using Http.

我想重定向url请求到HTTP到HTTPS。

I want to redirect url requests to HTTP to HTTPS.

我发现这个文档

因为它说我需要使用以下配置配置Apache后端

As it says I need to config the Apache backend with the following config

RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} =http

RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

我的问题是在哪里添加这些配置?

My Question is where to add these config?

还有另一个文档说我需要将.ebextensions目录添加到webapp目录并在那里放置配置。如果是这种情况,那么目录结构和配置文件格式是什么?

There is another document says i need to add .ebextensions directory to the webapp directory and place configurations there. If that is the case, then what is the directory structure and config file format ?

推荐答案

在项目的根目录中创建一个文件夹 .ebextensions (并确保它在你上传到Elastic Beanstalk的bundle的根目录中。像这样:

Create a folder .ebextensions in the root of your project (and make sure it is in the root of the bundle you're uploading to Elastic Beanstalk. Something like this:

~/workspace/my-app/
|-- .ebextensions
|   -- httpd
|      -- conf.d
|         -- myconf.conf
-- index.jsp

in myconf.conf

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

有一个整体有关自定义在Elastic Beanstalk Tomcat中运行的Java应用程序的文章: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform.html 查看更多信息。

There is a whole article on customizing the Java apps running in Elastic Beanstalk Tomcat: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform.html Have a look for more info.

这篇关于在Hlastic beanstalk loadbalancer中将Http Url重定向到Https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆