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
  • 43
  • 4
  • 1
    Does this answer your question? [Nginx location regex doesn't work with proxy pass](https://serverfault.com/questions/649151/nginx-location-regex-doesnt-work-with-proxy-pass) – djdomi Jan 06 '21 at 15:13
  • it exists a similar question already but i believe if you look at the location of phpmyadmin you may have forgotten something, to see what you've forgotten take a look at your WordPress location ;) – djdomi Jan 06 '21 at 15:15
  • The error message does not correspond to either of the two `server` blocks you posted. Please include the complete nginx configuration by running `nginx -T`. – Michael Hampton Jan 06 '21 at 18:42

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
  • 43
  • 4