{"id":1155,"date":"2012-08-27T17:10:52","date_gmt":"2012-08-27T09:10:52","guid":{"rendered":"http:\/\/rmohan.com\/?p=1155"},"modified":"2012-08-27T17:10:52","modified_gmt":"2012-08-27T09:10:52","slug":"ssl-redirect-on-ec2-instance-behind-ssl-terminating-load-balancer","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1155","title":{"rendered":"SSL redirect on EC2 instance behind SSL terminating load balancer"},"content":{"rendered":"<h3><img decoding=\"async\" src=\"http:\/\/adminsgoodies.com\/imgs\/question.png\" alt=\"Question\" \/><\/h3>\n<p>I\u2019m trying to redirect all url\u2019s to https in a web application.<\/p>\n<p>I have an ec2 instance behind an elastic load balancer. SSL is terminated on the load balancer.<\/p>\n<p>Any attempts at redirection end up giving me the familiar \u2018this page is requesting in a way which will never complete\u2019.<\/p>\n<p>The load balancer forwards 443 and 80 to port 80 on the instance.<\/p>\n<p>This is what I have in my .htaccess.<\/p>\n<pre><code>RewriteCond %{X-FORWARDED-PROTO} !=on <br \/>RewriteRule ^ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301] <\/code><\/pre>\n<p>Does anyone have any idea how to accomplish this? Kind thanks,<\/p>\n<div>\u00a0<\/div>\n<h3><img decoding=\"async\" src=\"http:\/\/adminsgoodies.com\/imgs\/answer.png\" alt=\"Answer\" \/><\/h3>\n<p>untested.. but I try this<\/p>\n<pre><code>RewriteCond %{HTTP:X-Forwarded-Proto} !https <br \/>RewriteRule ^ https:\/\/%{SERVER_NAME}%{REQUEST_URI} [L,R] <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"\n<p>I\u2019m trying to redirect all url\u2019s to https in a web application.<\/p>\n<p>I have an ec2 instance behind an elastic load balancer. SSL is terminated on the load balancer.<\/p>\n<p>Any attempts at redirection end up giving me the familiar \u2018this page is requesting in a way which will never complete\u2019.<\/p>\n<p>The load balancer forwards [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1155"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1155"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1155\/revisions"}],"predecessor-version":[{"id":1157,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1155\/revisions\/1157"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}