If this is set, use it instead of ServletRequest.getServerPort() for purposes of getRootUrlFromRequest().
Also treat the default port as scheme-specific in that method (which presumes that we in fact got the reported port right).
And enhance the reverse proxy setup monitor to validate that the Referer header (/manage)
actually matches what we have computed from getRootUrlFromRequest;
if it does not, something is messed up, though it may require some digging to find what.
(Would be better to let the monitor specify the exact problem it determined,
though this is not always actually possible;
for example if you are missing AllowEncodedSlashes NoDecode in Apache,
you just get a 404 from Apache without even getting to Jenkins.)
... based on Tyler's discovery at https://gist.github.com/rtyler/9195510
testRemoting(hudson.util.ProcessTreeTest) Time elapsed: 0.097 sec <<< ERROR!
java.util.NoSuchElementException: null
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:897)
at java.util.HashMap$ValueIterator.next(HashMap.java:922)
at hudson.util.ProcessTreeTest$MyCallable.call(ProcessTreeTest.java:42)
at hudson.util.ProcessTreeTest$MyCallable.call(ProcessTreeTest.java:38)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
He runs this on FreeBSD.
Seems to have caused spurious timeout errors.
https://jenkins.ci.cloudbees.com/job/core/job/jenkins_main_trunk/1748/testReport/junit/hudson.scheduler/CronTabEventualityTest/testFirstSundayOfMonthWillBeEventuallyTriggeredWithinOneMonthAndOneWeek_0_/
java.lang.Exception: test timed out after 1000 milliseconds
at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:242)
at java.io.File.exists(File.java:772)
at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:1072)
at sun.misc.URLClassPath.getResource(URLClassPath.java:199)
at java.net.URLClassLoader$1.run(URLClassLoader.java:358)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at hudson.scheduler.CronTab.set(CronTab.java:87)
at hudson.scheduler.CronTab.<init>(CronTab.java:83)
at hudson.scheduler.CronTab.<init>(CronTab.java:66)
at hudson.scheduler.CronTabEventualityTest.checkEventuality(CronTabEventualityTest.java:113)
at hudson.scheduler.CronTabEventualityTest.testFirstSundayOfMonthWillBeEventuallyTriggeredWithinOneMonthAndOneWeek(CronTabEventualityTest.java:109)