Skip to content

Commit 0e5c557

Browse files
authored
getRemoteAddress: Remove optional port number
The `HTTP_X_FORWARED_FOR` header might contain the IP address and the port number, when used via an IIS proxy. See https://serverfault.com/a/757994 As our setup requires the use of IIS as an incoming SSL proxy, this change allows the remote IP to be correctly detected. In my opinion, as the port number is allowed according to the linked RFCs, NC should handle this case.
1 parent c2266da commit 0e5c557

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

lib/private/AppFramework/Http/Request.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ public function getRemoteAddress(): string {
659659
if(isset($this->server[$header])) {
660660
foreach(explode(',', $this->server[$header]) as $IP) {
661661
$IP = trim($IP);
662+
// Use IP only, remove the optional port (see RFC 7239, Section 5.3 and RFC 7230, Section 5.4)
663+
$IP = explode(':', $IP)[0];
662664
if (filter_var($IP, FILTER_VALIDATE_IP) !== false) {
663665
return $IP;
664666
}

0 commit comments

Comments
 (0)