phpMyAdmin + HTTPS = Blödsinn

DeeDee0815

DeeDee0815

Doppel-As
Hallo,

ich bins mal wieder: Schon die Dritte frage zur Einrichtung meines Servers. In diesem Fall muss ich mich über phpMyAdmin aufregen: Eine in der Tat sehr gute MySQL-Verwaltung, die aber nicht nur vom Design von Version zu Version schlechter wird: Den Entwicklern fällt wohl nix neues mehr ein, sodass sie sich dazu entscheiden Fehler einzubauen.

Sinnvollerweise ist phpMyAdmin bei mir nur über https://phpmyadmin.meine-domain.de/ erreichbar. Wenn man sich nun anmelden will, macht phpMyAdmin scheiße: Redirect zu http://phpmyadmin.meine-domain.de:443/, was natürlich zu einem Bad Request führt.

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.


Ich habe schon versucht mithilfe der Configvariablen $cfg['Servers'][$i]['SignonURL'] und $cfg['PmaAbsoluteUri'] phpMyAdmin die richtige URL mitzuteilen doch vergeblich.

Was kann man da machen: Ich nutze phpMyAdmin 2.9.1.1-Debian-6 aus den offiziellen Debian-Repositorys, Debian Version ist Etch.

MfG
DeeDee0815
 
Hallo,

nachdem ich mich gestern den restlichen, und heute den ganzen Tag mit dem Versuch, eine Lösung für dieses Problem zu finden, beschäftigt habe, habe ich tatsächlich eine gefunden:

Im phpMyAdmin-Wiki steht zu der PmaAbsoluteUri-Geschichte folgendes:
But even if you set the correct URL yourself, you're fooled. phpMyAdmin will accidentally overwrite your correct value with an wrong guessed value. You need to fall back to version 2.7.0-pl2 ( 2005-12-27 15:08 ) it was messed up somewhere between version 2.8.0.3 and 2.8.2.4.

Finde ich ne klasse Idee, die Konfiguration des Benutzers zu überschreiben: Wer seine Benutzer vergräulen will, macht auf diese Weise sicher keinen Fehler. Wie kann man nur auf eine so dermaßen hirnrissige Idee kommen, die Konfiguration des Benutzers, die dieser immer dann tätigt, wenn es Probleme mit der "automatischen URL-Erkennung" gibt, mit der Fehl-Erkennung überschreiben! X(?(;(

Ich habe das Problem nun gelöst, in dem ich in der Datei /usr/share/phpmyadim/libraries/Config.class.php Zeile 690 (ungefähr) auskommentiert habe. (Ist hier am Ende des Quellcodes auch nochmal zu sehen.)

PHP:
<?php
...
    function checkPmaAbsoluteUri()
    {
        // Setup a default value to let the people and lazy syadmins work anyway,
        // they'll get an error if the autodetect code doesn't work
        $pma_absolute_uri = $this->get('PmaAbsoluteUri');
        $is_https = $this->get('is_https');

        if (strlen($pma_absolute_uri) < 5
            // needed to catch http/https switch
            || ($is_https && substr($pma_absolute_uri, 0, 6) != 'https:')
            || (!$is_https && substr($pma_absolute_uri, 0, 5) != 'http:')
        ) {
            $url = array();

            // At first we try to parse REQUEST_URI, it might contain full URL
            if (PMA_getenv('REQUEST_URI')) {
                $url = @parse_url(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
                if ($url === false) {
                    $url = array('path' => $_SERVER['REQUEST_URI']);
                }
            }

            // If we don't have scheme, we didn't have full URL so we need to
            // dig deeper
            if (empty($url['scheme'])) {
                // Scheme
                if (PMA_getenv('HTTP_SCHEME')) {
                    $url['scheme'] = PMA_getenv('HTTP_SCHEME');
                } else {
                    $url['scheme'] =
                        PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
                            ? 'https'
                            : 'http';
                }

                // Host and port
                if (PMA_getenv('HTTP_HOST')) {
                    if (strpos(PMA_getenv('HTTP_HOST'), ':') !== false) {
                        list($url['host'], $url['port']) =
                            explode(':', PMA_getenv('HTTP_HOST'));
                    } else {
                        $url['host'] = PMA_getenv('HTTP_HOST');
                    }
                } elseif (PMA_getenv('SERVER_NAME')) {
                    $url['host'] = PMA_getenv('SERVER_NAME');
                } else {
                    $this->error_pma_uri = true;
                    return false;
                }

                // If we didn't set port yet...
                if (empty($url['port']) && PMA_getenv('SERVER_PORT')) {
                    $url['port'] = PMA_getenv('SERVER_PORT');
                }

                // And finally the path could be already set from REQUEST_URI
                if (empty($url['path'])) {
                    if (PMA_getenv('PATH_INFO')) {
                        $path = parse_url(PMA_getenv('PATH_INFO'));
                    } else {
                        // PHP_SELF in CGI often points to cgi executable, so use it
                        // as last choice
                        $path = parse_url(PMA_getenv('PHP_SELF'));
                    }
                    $url['path'] = $path['path'];
                }
            }

            // Make url from parts we have
            $pma_absolute_uri = $url['scheme'] . '://';
            // Was there user information?
            if (!empty($url['user'])) {
                $pma_absolute_uri .= $url['user'];
                if (!empty($url['pass'])) {
                    $pma_absolute_uri .= ':' . $url['pass'];
                }
                $pma_absolute_uri .= '@';
            }
            // Add hostname
            $pma_absolute_uri .= $url['host'];
            // Add port, if it not the default one
            if (! empty($url['port'])
              && (($url['scheme'] == 'http' && $url['port'] != 80)
                || ($url['scheme'] == 'https' && $url['port'] != 443))) {
                $pma_absolute_uri .= ':' . $url['port'];
            }
            // And finally path, without script name, the 'a' is there not to
            // strip our directory, when path is only /pmadir/ without filename.
            // Backslashes returned by Windows have to be changed.
            // Only replace backslashes by forward slashes if on Windows,
            // as the backslash could be valid on a non-Windows system.
            if ($this->get('PMA_IS_WINDOWS') == 1) {
                $path = str_replace("\\", "/", dirname($url['path'] . 'a'));
            } else {
                $path = dirname($url['path'] . 'a');
            }

            // To work correctly within transformations overview:
            if (defined('PMA_PATH_TO_BASEDIR') && PMA_PATH_TO_BASEDIR == '../../') {
                if ($this->get('PMA_IS_WINDOWS') == 1) {
                    $path = str_replace("\\", "/", dirname(dirname($path)));
                } else {
                    $path = dirname(dirname($path));
                }
            }
            // in vhost situations, there could be already an ending slash
            if (substr($path, -1) != '/') {
                $path .= '/';
            }
            $pma_absolute_uri .= $path;

            // We used to display a warning if PmaAbsoluteUri wasn't set, but now
            // the autodetect code works well enough that we don't display the
            // warning at all. The user can still set PmaAbsoluteUri manually.
            // See
            // http://sf.net/tracker/?func=detail&aid=1257134&group_id=23067&atid=377411

        } else {
            // The URI is specified, however users do often specify this
            // wrongly, so we try to fix this.

            // Adds a trailing slash et the end of the phpMyAdmin uri if it
            // does not exist.
            if (substr($pma_absolute_uri, -1) != '/') {
                $pma_absolute_uri .= '/';
            }

            // If URI doesn't start with http:// or https://, we will add
            // this.
            if (substr($pma_absolute_uri, 0, 7) != 'http://'
              && substr($pma_absolute_uri, 0, 8) != 'https://') {
                $pma_absolute_uri =
                    (PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
                        ? 'https'
                        : 'http')
                    . ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//')
                    . $pma_absolute_uri;
            }
        }
        $this->set('PmaAbsoluteUri', $pma_absolute_uri); // <-- Auskommentieren !!!
        /*
         * #############################################################
         * # Die vorherige Zeile auskommentieren, sobald man in der    #
         * # config.inc.php die richtige absolute URL eingetragen hat. #
         * #############################################################
         */
    }
    ...
    ?>

Und überhaupt: Um ne URL auszulesen brauche ich zwölf Zeilen, und nicht eine dermaßen aufgeplusterte Funktion wie da oben, die teilweise einfach keinen Sinn ergibt:

PHP:
<?php
function checkPmaAbsoluteUri() {
	if ($this->get("PmaAbsoluteUri") == "") {
		if ($this->get("is_https")) {
			$protocol = "https://";
		} else {
			$protocol = "http://";
		}
		$host = $_SERVER['HTTP_HOST'];
		$uri = rtrim(dirname($_SERVER['PHP_SELF']), "/\\");
		$this->set("PmaAbsoluteUri", $protocol.$host.$uri);
	}
}
?>

Es gilt also die korrekte URL in der config.inc.php zu definieren:

Code:
$cfg['PmaAbsoluteUri'] = 'https://phpmyadmin.meine-domain.de/';

Dann muss man noch die oben aufgeführte Zeile auskommentieren und fertig.

FAZIT: Wie bereits erwähnt: phpMyAdmin wird immer schlechter: Noch ist es nicht soweit, dass das schlechte das Gute überwiegt, lange dauert es aber nicht mehr. Zum Glück ist bei Debian nicht immer die neuste Version dabei (also bei STABLE), denn sonst wäre die Version noch um einiges schlechter. Es wird sicher nicht mehr lange dauern, bis ich mich nach einer Alternative umsehen werde beziehungsweise muss.

MfG
DeeDee0815
 
Zuletzt bearbeitet:
Hallo DeeDee0815,

ich bin gerade beim stöbern über diesen Fred gestolpert. Vielen dank für info, ich hatte nämlich heute vor mir PhpMyAdmin zu installieren. Hast Du eine Idee, ab welcher Version sie den "mist" implementiert haben?

[...]

Es gibt dinge die kann man ab einem bestimmten stadium einfach nicht mehr verbessern, bzw. wenn dann meist nur noch verschlimmbessern. Schade das die entwickler diesen punkt offensichtlich übersehen haben - vom restlichen CODE mal ganz abgesehen, denn der ist bei genauer betrachtung an mehr als nur der oben genannten stelle dermaßen aufgebläht, dass man sich fragen muss ob sie vor lauter langer weile nichts besseres zu tun haben, als von version zu version immer mehr, statt weniger bugs einzubasteln. Den code habe ich mir das letzte mal vor ca einem jahr auf meinem windows system angesehen, und nach X-stunden codebereinigung zu gunsten der performance aufgegeben.


lg,
marco
 
Zuletzt bearbeitet:

Ähnliche Themen

Zugriff Ubuntu 16.04. auf Freigabe 18.04. LTS nicht möglich

Samba 4 Gast Zugang unter Ubuntu funktioniert nicht

Squid als RPCoHTTPS Proxy für Outlook Anywhere

Windows clients können nicht mehr auf lange laufendes System zugreifen

NagiosGrapher 1.7.1 funktioniert nicht

Zurück
Oben