重定向EC2 ELB从http到https [英] Redirecting EC2 elb from http to https

查看:1536
本文介绍了重定向EC2 ELB从http到https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要重定向所有的HTTP请求到https的ELB请求。我有2个EC2实例。我使用nginx的服务器。我已经尝试了重写nginx的conf文件没有任何成功。我喜欢的一些建议吧。

I want to redirect all the http request to https request on elb. I have 2 ec2 instances. I am using nginx for the server. I have tried a rewriting the nginx conf files without any success. I would love some advice on it.

推荐答案

ELB集 X-转发,原头,你可以用它来检测,如果原来的请求是HTTP和重定向到HTTPS呢。

ELB sets X-Forwarded-Proto header, you can use it to detect if original request was to HTTP and redirect to HTTPS then.

您可以在服务器试试这个 CONF:

if ($http_x_forwarded_proto = 'http') {
    return 301 https://yourdomain.com$request_uri;
}

看看<一href="http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/TerminologyandKeyConcepts.html#x-forwarded-headers">ELB文档。

这篇关于重定向EC2 ELB从http到https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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