I think most proxies will set the "X-Forwarded-Ssl" http header variable, or the "X-Forwarded-Proto" header (set to "https"). So you would have to check for this header and return the appropriate protocol. This specific use-case is getting more complex than intended (I still think, that being able to add headers is good).