我们都清楚,当我们访问一个网站,在浏览器地址栏出现了绿色框时,代表着这个网站支持https加密信息传输方式,证明你与网站之间的连接被加密了。为什么使用https访问会更安全呢?实际上,http面临的问题是,在访问过程中会出现窃听或嗅探,即在网络路由中,攻击者可以偷窥到你传输的内容。而https则采用对称加密+非对称加密+CA认证的3种方式,使传输过程更加安全可靠。
但是一些用户通过http访问的话,如何才能将http访问请求自动跳转至https访问呢,下面这个配置过程就可以实现。
只需配置ALB监听器即可
- 将ALB 80端口重定向至ALB 443端口。
- 将ALB 443端口转发至客户端自定义端口
- ALB DNS域名与域名服务商做CNAME解析
第一步,上传自己的域名证书。可通过控制台上传,也可以通过命令行上传。
命令行上传,参考:https://docs.aws.amazon.com/zh_cn/IAM/latest/UserGuide/id_credentials_server-certs.html
第二步,添加ALB监听器80重定向到443。
可以使用 redirect 操作将客户端请求从一个 URL 重定向到另一个。
第三步,正确配置目标组端口,并添加ec2实例
第四步,添加https 443转发后端目标组指定端口。
第五步,http访问域名,会自动跳转https访问
陈汉卿
云业务事业部 | 高级系统架构师
神州泰岳软件股份有限公司·AWS战略合作伙伴
We all know that when we visit a website and see a green box in the browser address bar, it means the website supports HTTPS encrypted communication, proving that the connection between you and the website is encrypted. Why is HTTPS access more secure? In fact, HTTP faces the problem of eavesdropping or sniffing during access - attackers on network routes can peek at the content you transmit. HTTPS uses three methods: symmetric encryption + asymmetric encryption + CA authentication, making the transmission process more secure and reliable.
But if some users access via HTTP, how can we automatically redirect HTTP requests to HTTPS access? The following configuration process can achieve this.
Just configure the ALB listener
- Redirect ALB port 80 to ALB port 443.
- Forward ALB port 443 to client custom port
- Configure CNAME resolution between ALB DNS domain name and domain registrar
Step 1: Upload your own domain certificate. You can upload via console or command line.
Command line upload reference: https://docs.aws.amazon.com/zh_cn/IAM/latest/UserGuide/id_credentials_server-certs.html
Step 2: Add ALB listener 80 redirect to 443.
You can use the redirect action to redirect client requests from one URL to another.
Step 3: Correctly configure the target group port and add EC2 instances
Step 4: Add HTTPS 443 forwarding to backend target group specified port.
Step 5: Access domain via HTTP, it will automatically redirect to HTTPS access
Chen Hanqing
Cloud Business Division | Senior System Architect
Shenzhou Taiyue Software Co., Ltd. · AWS Strategic Partner