Skip to content

OAuth, reverse proxy, real port number #9952

@fedy85

Description

@fedy85

Hi everyone,

i am running Roundcube 1.6.11 within mailcow docker container, having nginx proxy in front of it. First i've successfully configured roundcube-oauth plugin, which uses HTTP_X_FORWARDED_PORT for redirect_uri composition (if present). Ofcourse I would like to use native Roundcube OAuth support, but it composes the redirect_uri using $_SERVER['SERVER_PORT'] as can be seen in

$port = $_SERVER['SERVER_PORT'] ?? 0;

i think this could be enough to solve it (patch for version 1.6.11)


--- rcube_utils.php     2025-08-06 20:53:12.181573967 +0200
+++ rcube_utils.php.new 2025-08-06 20:51:15.692310219 +0200
@@ -1535,6 +1535,7 @@

             $host = $_SERVER['HTTP_HOST'] ?? '';
             $port = $_SERVER['SERVER_PORT'] ?? 0;
+            $port = $_SERVER['HTTP_X_FORWARDED_PORT'] ?? $port;

             $prefix = $schema . '://' . preg_replace('/:\d+$/', '', $host);
             if ($port && $port != $default_port && $port != 80) {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions