i have apache config in ec2 instance as:
RewriteEngine On
ProxyPreserveHost On
ProxyRequests On
ProxyPass /blog http://212.128.122.142/blog
this works until i point my dns record to ELB but not if i change my DNS to point at CDN. either i get 502 or redirect loop.
I also tried rewrite rule as i saw 502 bad gateway was because CDN tries to access as
myendpoint.elb.amazonaws.com/blog
and that wont be served by Apache, so, i changed so that apache accepts orgin endpoint as serverAlias and rewrite cond to rewrite url back to original hostname, and passing it to IP with proxypreserve.
RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com
RewriteCond %{HTTP_HOST} ^myendpoint.elb.amazonaws.com$
RewriteRule ^/blog http://mydomain/blog[R,L]
(i need to access /blog from different server hosted with same domain. And as mentioned above it all works until ELB is pointed to DNS Record but stops on CDN any heads up?)
What i am trying to achieve: host /blog in different server having this all working with cloudfront in top of ELB