如何在 Amazon Route53 中将 http 请求转发到 https? [英] How to forward http request to https in Amazon Route53?

查看:40
本文介绍了如何在 Amazon Route53 中将 http 请求转发到 https?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Amazon Route53 中有一个子域.比方说secure.example.com

I have a subdomain in Amazon Route53. Let's say secure.example.com

如果请求像 https://secure.example.com 一样,没关系,但我想强制 http 请求通过 https 来.当用户输入 http://secure.example.com 时,需要转发到 https://secure.example.com.

If requests come like https://secure.example.com it is ok but I would like to force http requests to come through https. When user types http://secure.example.com it needs to be forwarded to https://secure.example.com.

Amazon Route53中是否有域级重定向/转发请求通过httphttps?

Is there a domain level redirecting/forwarding requests coming through http to https in Amazon Route53?

推荐答案

不,没有办法做到这一点——因为它不是强制任何特定协议或将值从一个协议推送到另一个协议的 DNS 功能.您可以在 Web 服务器级别轻松完成此操作,无论是在 Apache、IIS 还是 NGINX 中.

No, there is no way to do this -- because it's not a DNS function to force any particular protocol, or to push values from one protocol to another. You can do this easily enough at the web server level, either in Apache, or IIS, or NGINX.

在任何一种情况下,将特定记录指向特定地址(无论是 IP 还是其他主机名)的 A 或 CNAME 值都是相同的,它只是通过端口 80 或端口 443 进行连接.

In any of those cases, the A or CNAME value pointing a specific record to a specific address (whether an IP or another host name) is the same, it's just going to connect via port 80 or port 443.

在 Apache 中,您可以简单地使用重写(首先启用 mod_rewrite):

In Apache, you can simply use a rewrite (enable mod_rewrite first):

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://www.host.com/$1 [R]

这篇关于如何在 Amazon Route53 中将 http 请求转发到 https?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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