I am using AWS Application load balancer to set up my environment.
Application load balancer receives requests from the Internet at port 443 and forwards it to port 80.
Apache server is running with docker on EC2 server on port 80 behind load balancer.
My website is developed using CakePHP.
When I called https://www.example.com, my webpage was loaded.
However, at PHP, when I used the following code to get the current url, the url I got is http://www.example.com. I am not getting https. I only get http.
echo Router::url('/', true);
So when the application makes an ajax call, the requests are coming over http (Not https) and browsers are rejecting the request as “blocked:mixed contents”. I think the requests should be coming out as https. Please point out what I am missing.
I tried the following and nothing work
In host file. (or) I put it in .htaccess
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}