Updated link generation to make use of X-Forwarded-* headers if these haven't been picked up by the servlet container.