Nginx Reverse Proxy to LAMP server : can’t login to phptheadmin

apache-2.4nginxphpmyadminreverse-proxy

I'm quite new to apache and even newer to reverse proxy, but I ended up installing a server with nginx (as a reverse proxy) and apache, to manage websites with different technologies. A php website (called php_site below) is handled by apache, a ruby on rails website is handled by nginx. More websites should be added later. Everything's working fine, except for phpmyadmin.

My problem : I can get to phpmyadmin login page (either through www.php_site.org/phpmyadmin/ or xx.xx.xx.xxx:8080/phpmyadmin/, xx being my server external IP), but I don't manage to log in. I'm pretty sure I have the good credentials, but when I submit the form, phpmyadmin login page simply reloads, without displaying errors.

My conf :

  • ubuntu 16.04
  • php 5.6 (because an old project needed it)
  • phpmyadmin 4.5.4.1
  • mysql 5.7.17
  • Apache/2.4.18

phpmyadmin is installed in /usr/share/phpmyadmin/.

Nginx conf (php_site) :

# /opt/nginx/conf/conf.d/php_site.conf 
server {
  listen 80;
  server_name www.php_site.org;

  location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

  location /phpmyadmin {
    proxy_pass http://127.0.0.1:8080/phpmyadmin;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

 client_max_body_size 15M;

}

server {
    listen 80;
    server_name php_site.org;
    rewrite ^ http://www.php_site.org$request_uri? permanent;
}

Apache conf (php_site) :

# /etc/apache2/sites-available/php_site.conf
NameVirtualHost  *:8080

<VirtualHost *:8080>

  ServerName www.php_site.org
  ServerAdmin myself@mail.com
  DocumentRoot /var/www/php_site.com/htdocs


  <Directory /var/www/php_site.com/htdocs >
    AllowOverride All
    DirectoryIndex index.php
  </Directory>

  ErrorLog /var/log/apache2/php_site-error.log

  LogLevel warn

  CustomLog /var/log/apache2/php_site.log combined

</VirtualHost>

<VirtualHost *:8080>
    ServerName php_site.org
    Redirect permanent / http://www.php_site.org/
</VirtualHost>

Questions :

Don't hesitate to ask fo further info if needed.

Best Answer

ok, kind of classical and ridiculous mystake of mine.

The problem actually originated in older changes in configuration files.

How did I got there : as AlexD advised, I checked more scrupulously my logs /var/log/apache2/php_site-error.log , and saw the following error when I tried to connect :

PHP Warning: Unknown: POST Content-Length of 122 bytes exceeds the limit of 20 bytes in Unknown on line 0.

This made me remember that I had made a change to /etc/php/5.6/apache2/php.ini a few days ago, to update upload file size. It seemed not to provide any errors since this day, reason why I didn't suspect this change.

In php.ini, I noticed : post_max_size = 15. The 'M' was missing. As soon as I changed to post_max_size = 15M and restarted apache, login problem was resolved.

Related Topic