如何在Amazon Route53中将http请求转发到https? [英] How to forward http request to https in Amazon Route53?
问题描述
我在Amazon Route53中有一个子域名。让我们说secure.example.com
I have a subdomain in Amazon Route53. Let's say secure.example.com
如果请求来自 https://secure.example.com
它是好的,但我想通过https强制 http
请求。当用户输入 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
.
是否有域级重定向/转发请求通过 http
到 https
in Amazon Route53
?
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.
在任何一种情况下,A或CNAME值指向特定地址(无论是IP还是其他主机名)的特定记录是相同的,它只是通过端口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屋!