Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The server is running Ubuntu 10.10, Apache 2.2.16, PHP 5.3.3-1ubuntu9.3, phpMyAdmin 3.3.7deb5build0.10.10.1. Since this same server is also running Zimbra on port 443, I've configured apache to serve SSL on port 81. So far, I have one CMS script running on this virtual host successfully.

However, when I access /phpmyadmin (set up with the default alias) on my custom ssl port and submit the login form, I am redirected to http://vhost.domain.com:81/index.php?TOKEN=foo (note the http:// instead of the https:// that the login url was using). This generates an Error 400 Bad Request complaining about "speaking plain HTTP to an SSL-enabled server port." I can then manually change the http:// to https:// in the URL and use phpmyadmin as expected.

I was annoyed enough to spend an hour trying to fix it and now even more annoyed that I cannot figure it out. I've tried various things, including:

  • Adding $cfg['PmaAbsoluteUri'] = 'https://vhost.domain.com:81/phpmyadmin/'; to the /usr/share/phpmyadmin/config.inc.php file but this did not correct the problem (even though /usr/share/phpmyadmin/libraries/auth/cookie.auth.lib.php looks like it should honor it and use it as the redirect).

  • Adding $cfg['ForceSSL'] = 1; to the same config.inc.php but then apache spirals into an infinite redirect.

  • Adding a rewrite rule to the vhost-ssl conf file in apache but I was unable to figure out the condition to use when http:// was present along with the correct ssl port of :81.

  • Lots of googling.

Here are the relevant Apache configuration pieces:

/etc/apache2/ports.conf

<IfModule mod_ssl.c>
    NameVirtualHost *:81
    Listen 81
</IfModule>

/etc/apache2/sites-enabled/vhost-nonssl

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName vhost.domain.com
        DocumentRoot /home/xxx/sites/vhost/html
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}:81%{REQUEST_URI}
</Virtualhost>

/etc/apache2/sites-enabled/vhost-ssl

<VirtualHost *:81>
        ServerAdmin webmaster@localhost
        ServerName vhost.domain.com
        DocumentRoot /home/xxx/sites/vhost/html
        <Directory />
                Options FollowSymLinks
                AllowOverride None

                AuthType Basic
                AuthName "Restricted Vhost"
                AuthUserFile /home/xxx/sites/vhost/.users
                Require valid-user
        </Directory>
        <Directory /home/xxx/sites/vhost/html/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

/etc/apache2/conf.d/phpmyadmin.conf

Alias /phpmyadmin /usr/share/phpmyadmin

(The rest of the default .conf truncated.)

Everything in the apache config seems to work ok - the rewrite from non-ssl to ssl, the http authentication, the problem only happens when I am submitting the login form for phpmyadmin from https://vhost.domain.com:81/index.php.

Other configs:

The phpmyadmin config is completely default and the php.ini has only had some minor changes to memory and timeout limits. These seem to work fine, as mentioned, another php script runs with no problem and phpmyadmin works great once I manually enter in the correct schema after login.

I'm looking for either a bandaid I can add to save me the trouble of manually entering in the https:// after login, a real fix that will make phpmyadmin behave as I think it should or some greater understanding of why my desired config is not possible.

share|improve this question
add comment

1 Answer

An old version of phpmyadmin that I have lying around has this in /phpmyadmin/config.inc.php

$cfg['PmaAbsoluteUri'] = 'http://127.0.0.1/phpmyadmin';

You could try changing the http to https(and other values appropriately) and see if that makes a difference.

share|improve this answer
    
Thanks for the response. Unfortunately, that's the first thing I tried (see above) - glancing at the php code even looks like it should use it, but before I started debugging the actual code figured I'd ask around, see if there was something else I might be missing. –  baraboom Jul 1 '11 at 13:47
    
Worked perfectly for me. Thanks +1 –  Gerben Oct 11 '12 at 16:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.