Checking for SSL in a view

Here's the situation:

* I have a site where a few pages are ssl-required but the whole site
is ssl-allowed. (In other words, most of the site can be reached by
either https or http.)

* In order to minimize user's browser warnings, I want to use https
for all assets on pages when the request is https. This is easy for
requests on the same host (e.g. css, javascript since we are not using
a separate asset host yet) but some images are hosted by an off-site
server.

* These images have https versions available, but on a different host,
e.g. regular images are at http://images.example.com/images/filename.jpg
but secure at https://ssl-images.example.com/images/filename.jpg. I
have tweaked my image-URL-producing functions to produce the right
image URL when they are asked, e.g. def get_image_url(ssl=false), so
get_image_url returns http://images.example.com and
get_image_url(true) returns https://ssl-images.example.com.

How do I know, inside a view, when to ask that function for SSL and
when not?

* request.ssl? doesn't appear to be available inside views. (Not
surprising given that it's part of ActionController.)

* I tried setting a global variable inside the controller (e.g.
@ssl_request = request.ssl?) but for some reason that's not working,
either.

It seems as though Rails is not getting the message that the request
is SSL. I'm using Nginx + Passenger for hosting; is there something
similar to the "proxy_set_header X-FORWARDED_PROTO https;" which
should be used when the request isn't being proxied?

Thanks,

pjm