If the SSL certificate is on the proxy server rather than the web server, then the typical ways of detecting a secure connection with Request.IsSecureConnection doesn't work because from the web server point of view it is running http over port 80 even though the proxy server is using SSL. So this makes it difficult to do the redirecting correctly.
What you need to find out is if the proxy server is sending some alternate way for the web server to detect if it is a secure request. Probably it sets a custom server variable but I would need to know what it is providing then maybe I can tell you something to try configuration that may make it work. I don't know anything about UAG, so you'll have to do the research on it and tell me if it does provide a custom server variable for secure requests and if so what that variable is.
Best,
Joe