0

So I have two nginx server in a kubernetes cluster. I want that one nginx server acts as a reverse proxy for the other that serves my phpmyadmin files.

For accessing my phpmydadmin from the first server, the user has to type: https://mynginx.example/phpmyadmin From that I want my nginx server to rewrite the URI before he proxy pass with replacing /phpmyadmin by /.

I write this for now

      location                /phpmyadmin {
            rewrite           /phpmyadmin(/.*) $1 break;
            proxy_pass        https://phpmyadmin.default.svc.cluster.local:5000;
      }

But actually when it returns me 404 error and when I saw logs on nginx that serves phpmyadmin I see:

19 open() "/var/www/localhost/htdocs/phpmyadmin/phpmyadmin" failed (2: No such file or directory)

It doesn't seem to replace my /phpmyadmin by /.

All my config file is:

server {
        listen                  80 default_server;
        listen                  [::]:80 default_server;
    return                  301 https://$host$request_uri;

}

server { listen 443 ssl default_server; root /www; index index.html;

  ssl_certificate         /tls/tls.crt;
  ssl_certificate_key     /tls/tls.key;

  location                /phpmyadmin {
        rewrite           /phpmyadmin(/.*) $1 break;
        proxy_pass        https://phpmyadmin.default.svc.cluster.local:5000;
  }

  location                ~ /wordpress(.*) {
        return            307 $scheme://$host:5050$1;
  }

}

nail0x
  • 63
  • 2
  • 6

1 Answers1

0

I fixed it ! It was an issue with my regex (/.*), I remove the / and now it works Thanks for your helps and suggestion I follow the links and learned some things x)

nail0x
  • 63
  • 2
  • 6