0

When trying to make phpmyadmin work on my Nginx server, it rewrites the request https://fellowshipmedia.eu/phpmyadmin to https://fellowshipmedia.eu/index.php.

I tried to read the error.log with 'rewrite_log' and 'debug' flag set, but the log is very hard to understand for me. I can see that at a certain point the prefix of the path gets dropped, but why?

This is part of the nginx conf file:

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        ssl_certificate /etc/letsencrypt/live/fellowshipmedia.eu/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/fellowshipmedia.eu/privkey.pem;
        include snippets/ssl-params.conf;

        server_name fellowshipmedia.eu;
        root /usr/share/nginx/html/fellowshipmediaeu/httpsdocs/;
        index index.php index.html index.htm ;



        location / {
            try_files $uri $uri/ /index.php?page=$uri;
        }


        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

}

This is the access.log:

    86.83.94.220 - - [10/Jun/2017:07:24:10 +0200] "POST /phpmyadmin/index.php HTTP/2.0" 302 619 "https://fellowshipmedia.eu/phpmyadmin/index.php?db=&token=66594ef803698c67dfd27ab17d089a78&old_usr=root" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"
    86.83.94.220 - - [10/Jun/2017:07:24:10 +0200] "GET /index.php?token=cd06ccda9c2d36a7600e99474755558a HTTP/2.0" 404 233 "https://fellowshipmedia.eu/phpmyadmin/index.php?db=&token=66594ef803698c67dfd27ab17d089a78&old_usr=root" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0"

This is the error.log: https://pastebin.com/0BKXVjza

This is fastcgi-php.conf:

fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
C.A. Vuyk
  • 632
  • 10
  • 18

2 Answers2

1

It is phpmyadmin which redirects initial request to incorrect /index.php with status 302. Check that phpmyadmin receives initial request with correct prefix through FastCGI - this part is missing from your logs and depends on content of snippets/fastcgi-php.conf which is also missing from your post. Also check phpmyadmin own setting, e.g PmaAbsoluteUri.

AlexD
  • 8,747
  • 2
  • 29
  • 38
  • Thank you for your answer. I've updated the question with the missing pieces. However I could not find the phpmyadmin configuration file and the PmaAbsoluteUri, could you give me directions where to find that? – C.A. Vuyk Jun 12 '17 at 12:26
  • Found the config file and changed PmaAbsoluteUri. It works now, thanks for the hint. However strange this setting is needed... – C.A. Vuyk Jun 13 '17 at 08:23
0

I found another answer in this thread: Nginx phpmyadmin redirecting to / instead of /phpmyadmin upon login

Add this to the serverblock to help phpmyadmin find its location:

# Phpmyadmin Configurations
    location /phpmyadmin {
       root /usr/share/;
       index index.php index.html index.htm;
       location ~ ^/phpmyadmin/(.+\.php)$ {
               try_files $uri =404;
               root /usr/share/;
               #fastcgi_pass 127.0.0.1:9000;
               #fastcgi_param HTTPS on; # <-- add this line
               fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
               fastcgi_index index.php;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               include fastcgi_params;
       }
       location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
               root /usr/share/;
       }
   }

   # Dealing with the uppercased letters
   location /phpMyAdmin {
       rewrite ^/* /phpmyadmin last;
   }
C.A. Vuyk
  • 632
  • 10
  • 18