mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-18 06:22:29 +00:00
You have just got to love people using non-standard headers...
This commit is contained in:
1 parent
17fdfab3cd
commit
19d8b80bb2
1 file changed
+16
-1
@@ -1923,8 +1923,23 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
|
||||
String scheme = getXForwardedHeader(req, "X-Forwarded-Proto", req.getScheme());
|
||||
buf.append(scheme).append("://");
|
||||
String host = getXForwardedHeader(req, "X-Forwarded-Host", req.getServerName());
|
||||
buf.append(host);
|
||||
int index = host.indexOf(':');
|
||||
int port = req.getServerPort();
|
||||
if (index == -1) {
|
||||
// Almost everyone else except Nginx put the host and port in separate headers
|
||||
buf.append(host);
|
||||
} else {
|
||||
// Nginx uses the same spec as for the Host header, i.e. hostanme:port
|
||||
buf.append(host.substring(0, index));
|
||||
if (index + 1 < host.length()) {
|
||||
try {
|
||||
port = Integer.parseInt(host.substring(index + 1));
|
||||
} catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
// but if a user has configured Nginx with an X-Forwarded-Port, that will win out.
|
||||
}
|
||||
String forwardedPort = getXForwardedHeader(req, "X-Forwarded-Port", null);
|
||||
if (forwardedPort != null) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user