Adding SSL communication between ELB EC2 on AWS and forcing only HTTPS comunication

时光怂恿深爱的人放手 提交于 2020-01-04 07:27:24

问题


I am trying to add SSL support for my site which is on AWS infrastructure.

I am using (Ubuntu, Apache, cake-php).

I installed the certificate from go daddy on AWS ELB per this guide.

When I test my domain via HTTPS it works fine, but the site is also available via HTTP.

I would like to redirect all calls to HTTP, but per the guide instructions the ELB and EC2 communicate via HTTP, so the protocol identified by my EC2 is on port 80, so the EC2 has no way to redirect the user, because all communication to it from ELB is over port 80.

If I change ELB-EC2 settings to HTTPS, it does not work anymore, I assume some configuration is required (on ELB,EC2?) but I could not find any documentation on the above.

Any input, links etc. would be greatly appreciated! Thanks


回答1:


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

Take a look at ELB docs.



来源:https://stackoverflow.com/questions/24508312/adding-ssl-communication-between-elb-ec2-on-aws-and-forcing-only-https-comunicat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!