# Alias causing phpMyAdmin login endless loop

**URL:** <https://www.ruby-forum.com/t/alias-causing-phpmyadmin-login-endless-loop/201863>\
**Category:** NGINX\
**Created:** [January 16, 2011, 5:29pm UTC](https://www.ruby-forum.com/t/alias-causing-phpmyadmin-login-endless-loop/201863 "2011-01-16T17:29:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 16, 2011, 5:29pm UTC](https://www.ruby-forum.com/t/alias-causing-phpmyadmin-login-endless-loop/201863/1 "2011-01-16T17:29:58Z")

</div>

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  
path.

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):

```auto
location ~ ^/phpmyadmin/(.*\.php)$ {
    alias /usr/share/phpMyAdmin/$1;
    fastcgi_pass 127.0.0.1:9000;
    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:

> **[Alias causing phpMyAdmin login endless loop](https://forum.nginx.org/read.php?2,166700,166700#msg-166700)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![stickaforkinme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stickaforkinme](https://www.ruby-forum.com/u/stickaforkinme)\
**Post date:** [February 18, 2011, 10:07am UTC](https://www.ruby-forum.com/t/alias-causing-phpmyadmin-login-endless-loop/201863/2 "2011-02-18T10:07:49Z")

</div>

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

Posted at Nginx Forum:

> **[Re: Alias causing phpMyAdmin login endless loop](https://forum.nginx.org/read.php?2,166700,176403#msg-176403)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![stickaforkinme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stickaforkinme](https://www.ruby-forum.com/u/stickaforkinme)\
**Post date:** [February 18, 2011, 5:42pm UTC](https://www.ruby-forum.com/t/alias-causing-phpmyadmin-login-endless-loop/201863/3 "2011-02-18T17:42:25Z")

</div>

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

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

```auto
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 {
    proxy_pass http://127.0.0.1:xyz;
    ...
  }
}
```

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:

> **[Re: Alias causing phpMyAdmin login endless loop](https://forum.nginx.org/read.php?2,166700,176509#msg-176509)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![stickaforkinme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stickaforkinme](https://www.ruby-forum.com/u/stickaforkinme)\
**Post date:** [March 8, 2011, 2:38am UTC](https://www.ruby-forum.com/t/alias-causing-phpmyadmin-login-endless-loop/201863/4 "2011-03-08T02:38:18Z")

</div>

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  
issue…

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\_add\_x\_forwarded\_for;  
proxy\_set\_header Host $http\_host;  
proxy\_redirect off;  
proxy\_read\_timeout 300;  
proxy\_pass [http://mongrel/](http://mongrel/);  
}

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

```

$document\_root$fastcgi\_script\_name;  
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:

> **[Re: Alias causing phpMyAdmin login endless loop](https://forum.nginx.org/read.php?2,166700,181121#msg-181121)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![stickaforkinme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stickaforkinme](https://www.ruby-forum.com/u/stickaforkinme)\
**Post date:** [February 26, 2011, 10:17pm UTC](https://www.ruby-forum.com/t/alias-causing-phpmyadmin-login-endless-loop/201863/5 "2011-02-26T22:17:03Z")

</div>

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  
days.

Posted at Nginx Forum:

> **[Re: Alias causing phpMyAdmin login endless loop](https://forum.nginx.org/read.php?2,166700,178660#msg-178660)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![stickaforkinme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stickaforkinme](https://www.ruby-forum.com/u/stickaforkinme)\
**Post date:** [March 8, 2011, 11:39pm UTC](https://www.ruby-forum.com/t/alias-causing-phpmyadmin-login-endless-loop/201863/6 "2011-03-08T23:39:40Z")

</div>

## 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 ☹

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,166700,181440#msg-181440](http://forum.nginx.org/read.php?2,166700,181440#msg-181440)
