[FIXED JENKINS-10675] use X-Forwarded-Proto if present

Wrote this fix to make Jenkins work correctly when running behind a reverse proxy that adds an X-Forwarded-Proto HTTP header (e.g. nginx, apache, Amazon ELB)