Adding SSL communication between ELB EC2 on AWS an

2019-07-24 09:07发布

问题:

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.