I need to set up an iRule with an SSL certificate which connects the 443 port to the 80 of the backend servers (the communication between the balancer and backends are in plain http). Problem is that my app is a Ruby on Rails app which needs to detect that the origin request was done in HTTPS to properly redirect and provide https urls.
The framework can read the following headers: (rails request.rb code snippet)
def scheme
if @env[‘HTTPS’] == ‘on’
‘https’
elsif @env[‘HTTP_X_FORWARDED_SSL’] == ‘on’
‘https’
elsif @env[‘HTTP_X_FORWARDED_SCHEME’]
@env[‘HTTP_X_FORWARDED_SCHEME’]
elsif @env[‘HTTP_X_FORWARDED_PROTO’]
@env[‘HTTP_X_FORWARDED_PROTO’].split(‘,’)[0]
else
@env[“rack.url_scheme”]
end
end
How can i inject one of those headers? (ie: HTTP_X_FORWARDED_SCHEME=https) or should the iRule do this automatically for me when configuring certificates on it?
PS: Sorry about my iRule’s technical level. I’m the developer behind the F5 balancer needing this simple header so my app can redirect properly to https urls
It’s unlikely you’d need to use an iRule to configure the SSL termination on the F5, normally a ClientSSL profile would be used. You can use an iRule like this to insert the header - note I’ve assumed the value should be ‘on’ not ‘https’ as you think but I could be wrong;
when HTTP_REQUEST {
[HTTP::Header] insert HTTP_X_FORWARDED_SSL "on"
}