Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Jan 20, 2015 6:27 am 
Offline
User avatar

Joined: Tue Jan 20, 2015 6:09 am
Posts: 1
Hello,

We have setup 2 port configurations under our NodeBalancer. 1 for http traffic running through port 80, and another for HTTPS traffic running through port 443.
Both port configurations connect to the same Linode on port 80. We have SSL connections terminating at the Nodebalancer.

In our virtualhost config for the Linode we have the following rewrite rules (there's obviously a lot more setup in there regarding serverName, DocumentRoot etc) so for brevity here's the rewrite rules only.

<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,L]
</VirtualHost>

We would like all traffic to end at the URL https://churchconnect.io/***** whether they've come from http or https, with or without www. in the hostname.

For http traffic, those rewrite rules remove the www. part of the host and point the url through to https.
This works great for the following URLs:
http://www.churchconnect.io » https://churchconnect.io
https://www.churchconnect.io » http://churchconnect.io

This URL just works:
https://churchconnect.io » https://churchconnect.io

However the following URL does NOT redirect properly (notice it doesn't end at https):
http://churchconnect.io » http://churchconnect.io

I realise that the redirect rule is only affecting connections made with a www. but I can't figure out how to redirect all traffic through to https without there being a infinite redirect loop occurring. I believe this is because all connections between the NodeBalanacer and the Linode are http only. I'd be happy to write specific rewrite rules under a <VirtualHost *:443></VirtualHost> directive but I don't think any connections will ever get there from the NodeBalancer.

Does anyone have any smart redirect rules that could work under this circumstance? Or do I need to setup the Nodebalancer to pass on the SSL termination directly to the Lindoes themselves by connecting over port 443 using just a TCP connection?

Many thanks,


Top
   
PostPosted: Tue Jan 20, 2015 9:34 am 
Offline
Senior Member

Joined: Sat Nov 27, 2010 8:21 pm
Posts: 63
This should work:

Code:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [L,R=301]


Based on http://technosophos.com/2012/08/13/rewr ... oxies.html

If HTTP or HTTPS is selected, the NodeBalancer will add an X-Forwarded-Proto header, with a value of either http or https, to all requests sent to the backend. The header value is based on the type of request (HTTP or HTTPS) originally received by the NodeBalancer.

https://www.linode.com/docs/platform/no ... ence-guide


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group