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

Stefan Scott lists at ruby-forum.com
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, mydom.myvpshost.com/phpmyadmin).

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;
  server_name mydom.myvpshost.com;

  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_ciphers
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
  ssl_prefer_server_ciphers   on;

  location /phpmyadmin/ {
    rewrite ^/phpmyadmin(/.*)$ $1 break;
    index index.php;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9000;
    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;
  server_name mydom.myvpshost.com;
  location / {
    rewrite ^/phpmyadmin(.*) https://mydom.myvpshost.com/phpmyadmin$1
permanent;
  }
}

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

http://mydom.myvpshost.com/phpmyadmin

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

https://mydom.myvpshost.com/index.php?token=290761b728bd2bfac2953354fbf3e9bb

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:

https://mydom.myvpshost.com/phpmyadmin/index.php?token=28f650a617ac1ae9b1842243eae2d8aa

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

I know this problem wouldn't be happening if I used a vhost in the URL
(eg, phpmyadmin.mydom.myhost.com) - but in this case I want to use a
subdir in the URL (eg, mydom.myhost.com/phpmyadmin).

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
here?

Thanks.

- Stefan Scott
-- 
Posted via http://www.ruby-forum.com/.





More information about the nginx mailing list