On 01/07/06, MIYASHITA kensuke [email protected] wrote:
On my server, stunnel is running to accept HTTPS (port 443) connection
from clients and redirect them to localhost:80. And on port 80 of my
server, WEBrick is running to accept HTTP connection.
In such situation, WEBrick generates URLs beginning with ‘http://’,
not with ‘https://’. So one can access to ‘https://myserver/’, but
when he click on any hyperlinks on this page, he access via http to
How can I make WEBrick to generate URLs with ‘https://’ always?
If rails sees a header such as this then it will generate https urls
with link_to, url_for and the like:
With a apache fronted mongrel cluster I use the following directive to
let rails know:
RequestHeader set X_FORWARDED_PROTO ‘https’
I would imagine if you want to get WEBrick to always use https there’s
probably a way to do it in your environment.rb. The two things that
are checked are:
@env[‘HTTPS’] == ‘on’ || @env[‘HTTP_X_FORWARDED_PROTO’] == ‘https’
So if you can somehow set those in an application-wide before filter
you might get away with it.