File Not Found logging in w/ nginx+phpMyAdmin in URL subdir

Stefan Scott lists at
Sat Feb 14 01:49:01 MSK 2009

Hello -

I'm using the nginx.conf file below to try to run phpMyAdmin with SSL
and FastCGI in a subdirectory (eg,

It works except after I hit GO on the phpMyAdmin login screen - when the
rewrite rule drops the "phpmyadmin" from the middle of the URL and the
browser displays "404 Not Found - nginx/0.6.33" - then if I add
"phpmyadmin" back in the middle of the rewritten URL it works fine for
the rest of the phpMyAdmin session.

server {
  listen 443;

  ssl                 on;
  ssl_certificate     /etc/ssl/certs/myssl.crt;
  ssl_certificate_key /etc/ssl/private/myssl.key;

  access_log /usr/local/nginx/logs/phpmyadmin.access_log;
  error_log  /usr/local/nginx/logs/phpmyadmin.error_log;

  ssl_session_timeout  5m;

  ssl_protocols  SSLv2 SSLv3 TLSv1;
  ssl_prefer_server_ciphers   on;

  location /phpmyadmin/ {
    rewrite ^/phpmyadmin(/.*)$ $1 break;
    index index.php;
    fastcgi_index index.php;
    root /home/myname/sources/phpmyadmin/;

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS on;
    include /usr/local/nginx/conf/fastcgi_params.phpmyadmin;

server {
  listen     80;
  location / {
    rewrite ^/phpmyadmin(.*)$1

So I can display the phpMyAdmin login screen (and get the self-signed
SSL certificate dialog the first time around), by going here:

I enter the Username and Password and hit GO, and then the browser shows
a new URL like this:

So it redirected from http to https, and it also dropped the
"phpmyadmin" part in the middle, because of the rewrite rule. Since the
root directive is /home/myname/sources/phpmyadmin/ (the location of
phpMyAdmin on my server), I thought this would work - but it doesn't.

I'm actually able to manually fix this by altering this URL in the
browser just this one time, inserting the "phpmyadmin" part in the
middle, like this:

>From then on everything works fine for the rest of the phpMyAdmin

I know this problem wouldn't be happening if I used a vhost in the URL
(eg, - but in this case I want to use a
subdir in the URL (eg,

I've been sitting here for two days pulling my hair out trying to get
this right. Can anyone tell me what's wrong with my nginx.conf file


- Stefan Scott
Posted via

More information about the nginx mailing list