We are using Network level Loadbalancer, which redirects all the http calls to https.
The site hosting is configured where our SSL certificates are installed on the load balancer rather than in Apache Proxy (SSL offloading).
Apache web server is used only as a reverse proxy(via mod_proxy).
This results in the traffic between the load balancer and the Apache Proxy taking place over HTTP (unencrypted).
1. http://example.com (hit on browser)
2. https://example.com (redirection via LB)
3. https://example.com (hit on browser)
4. http://example.com/uri (Apache web server via mod_rewrite)
(The issue is that Apache Proxy is unaware that the original protocol was HTTPS and sends back an HTTP reference.)
5. https://example.com/uri (Load Balancer again redirects it to https).
The combination of SSL offloading and the reverse proxy rewriting the URL (only once) is resulting in the initial request to the application to flap between HTTP and HTTPS twice.
Workaround tried : RequestHeader set X-Forwarded-Proto https (No luck).