Alias causing phpMyAdmin login endless loop

Recently I’ve been trying to set up a web server using Nginx (I normally
use Apache). However I’ve ran into a problem trying to set phpMyAdmin up
on an alias. The alias correctly takes you too the phpMyAdmin login
screen, however when you enter valid credentials and hit go you end up
back on the login screen with no errors.

Sounded like a cookie or session problem to me… but if I symlink the
phpMyAdmin directory and try logging in through the symlinked version it
works fine! Both the symlink and the alias one set the same number of
cookies and both set seem to set the cookies for the correct domain and

My Nginx config for the php alias is as follows (which seems to be
correct based on the googling I’ve done on the problem):

location ~ ^/phpmyadmin/(.*\.php)$ {
    alias /usr/share/phpMyAdmin/$1;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;

I’m running Nginx 0.8.53
PHP 5.3.3
MySQL 5.1.47
phpMyAdmin 3.3.9 - self install
And php-mcrypt is installed.

Anyone have any ideas about how to fix it?

Posted at Nginx Forum:,166700,166700#msg-166700

Hello stickaforkinme. I have the same problem. Have you find a

Posted at Nginx Forum:,166700,176403#msg-176403

“location ~ ^/phpmyadmin/(.*.php)$” -->> How about all the other
phpMyAdmin files that are not .php files?

This works for me (Replace ‘proxy’ with ‘fastcgi’).

server {
  location ~ .+\.php$ {
    # Return '400 Bad Request' for dodgy urls;
    location ~ \..*/.*\.php$ {
      return 400;
    # Send others to proxy;
    error_page 402 = @proxy;
    return 402;
  location ~ ^/phpMyAdmin/(.*)$ {
    alias /server/path/to/phpMyAdmin/;

    # Require authentication
    auth_basic "Area-Name";
    auth_basic_user_file htpasswd-file;

    # Serve static files directly and pass dynamic requests to proxy;
    try_files $uri $uri/ @proxy;
  location @proxy {

The setup means all phpMyAdmin request go through the phpMyAdmin
location first.

As said, swap fastcgi for proxy and should be good to go.

Posted at Nginx Forum:,166700,176509#msg-176509

This problem is not limited to just phpMyAdmin. I am trying to do the
same thing using nginx 0.7.65 (ubuntu 10.04 stable nginx package) in a
vhost that uses / for a RoR application via mongrel_cluster and then I
want multiple php aliases to reside under / like /opensis and
/phpmyadmin, and both programs experience the same login endless loop

In this case I cannot simply use a symlink because I want to run a php
application in an alias folder inside the RoR application.

Here are my current location blocks including the mongrel_cluster
location which is the first one:

    location / {
       root /var/www/sis/public;
       proxy_set_header  X-Real-IP        $remote_addr;
       proxy_set_header  X-Forwarded-For

proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 300;
proxy_pass http://mongrel/;

    location ~ ^/phpmyadmin/(.*\.php)$ {
       alias /var/www/phpmyadmin/$1;
       fastcgi_param HTTPS on;
       fastcgi_param SCRIPT_FILENAME

include fastcgi_params;

    location = /phpmyadmin {
       rewrite ^ $scheme://$host$uri/ permanent;

    location /phpmyadmin/ {
       index index.php;
       alias /var/www/phpmyadmin/;

The above configuration gets me closer than anything else I have found
so far. PHP is served and the default document defaults to index.php for
the alias but for some reason it is still not the right configuration
because of the login loop issue.

Hopefully one of the devs can respond to this with a working
configuration. I think part of the problem is that everyone is using
different versions of nginx and bug fixes and code changes have modified
how aliases function in nginx.

Who knows, maybe my whole problem is an outdated version of nginx…

Posted at Nginx Forum:,166700,181121#msg-181121

I decided to cheat and solve the problem using a symlink (not really how
I wanted to do it but know at the time seemed to have a solution)…
however I might give Dayo’s method a whirl some time in the next few

Posted at Nginx Forum:,166700,178660#msg-178660

acjohnson Wrote:

Who knows, maybe my whole problem is an outdated
version of nginx…

I’m running 0.8.53 on CentOS and the problem is still there :frowning:

Posted at Nginx Forum:,166700,181440#msg-181440

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs