I'm using nginx as reverse proxy for my VMs. When I try to authenticate myself in a my website, or in phpmyadmin, nginx return the reponse from the local IP when the POST is from a domain!

Look: Nginx return a local IP instead the domain name

Here i'm trying to authenticate to phpmyadmin. When I valid, I have to refresh the page to connect successfully.

This is my nginx configuration:

server {
    listen 80;
    server_name     mysql.mydomain.com;
    location / {

My default file is:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        location / {
                try_files $uri $uri/ =404;
                proxy_set_header    Host                $http_host;
                proxy_set_header    X-Real-IP           $remote_addr;
#               proxy_set_header    X-Forwarded-Ssl     on;
                proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
                fastcgi_param REMOTE_ADDR $http_x_real_ip;

                proxy_set_header    X-Forwarded-Proto   $scheme;
                proxy_set_header    X-Frame-Options     SAMEORIGIN;

        # Pour let's encrypt
        location '/.well-known/acme-challenge' {
                default_type "text/plain";
                root         /root/certbot-auto/;

        # On interdit tout autre appel
        location ~ /\. {
                deny all; access_log off; log_not_found off;

I'm using CloudFlare for SSL certification. If needed, I can use Let's Encrypt with Nginx. Apache is using for Phpmyadmin, and the other services on other VMs.

I search on internet since yesterday morning, but I didn't found anything about this kind of problem. Do you know what is going wrong ?

  • Your question is imprecise. Can you edit your question to show an example of something not working? For example you could add a curl showing what happens, describe what you expect to happen, and show any applicable logs - web server access, error, and back end system. – Tim Jul 13 '17 at 22:38
  • Excuse me but I don't know which log I could show you ... I'm not very good this nginx, could you please give me a command I can make ? – poka Jul 13 '17 at 23:04

This doesn't have anything to do with nginx actually.

When you do a POST request to log-in to PHPMyAdmin, PHPMyAdmin sends back a 302 redirect to the index.php page, which causes your browser to try to load page from wrong address.

So, you have to fix the base URL setting in PHPMyAdmin, so that it will generate correct URLs with correct domain name.

The setting you need to add to PHPMyAdmin configuration is:

$cfg['PmaAbsoluteUri'] = 'https://mysql.example.com/';

This option is documented in https://docs.phpmyadmin.net/en/latest/config.html#basic-settings.

|improve this answer|||||
  • Ok, you should be right, but the thing is, I didn't touch anything in the configuration of phpmyadmin. Why does he make that ? – poka Jul 13 '17 at 22:52
  • Also, the problem is only when I try to log in. Then, the page is looping just on the POST and GET request I shown to you. So here when I refresh the page, it's ok i'm authenticate to phpmyadmin with no probleme... And this problem is same with another website in another VM of my server. Completely another website, and just when I try to log in again... – poka Jul 13 '17 at 23:00
  • When you are running through a proxy, PHPMyAdmin thinks it is reachable at the same address as its local address is. This is true when there is no proxy in front of PHPMyAdmin. However, when proxy is added in front of it, the situation changes. What comes to your application, the same thing happens there. It generates URLs in its responses with its own hostname, which is not reachable when a reverse proxy is used. You should change the application so that it generates proper URLs. – Tero Kilkanen Jul 13 '17 at 23:45
  • I added the exact setting information to my answer. – Tero Kilkanen Jul 13 '17 at 23:50
  • Ok I copy config.sample.inc.php to config.inc.php, puted the line: $cfg['PmaAbsoluteUri'] = 'https://mysql.example.com/'; I reloaded apache, but nothing changed. Did I forget something ? Should I reinstall phpmyadmin ? – poka Jul 14 '17 at 0:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.